-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: GroupBy using column alias not working with SQL server #159
Comments
You also have this issue if you also provide a |
I'll be able to verify that tomorrow. The problem is, that the Source: http://tinman.cs.gsu.edu/~raj/sql/node22.html We just recently started transitioning from the old nestjs-query package to this. |
Will see if I can try to reproduce this, there is not anything special that you are doing? As, in my own projects everything works and all tests also passed. |
No, not really. I have a custom typeorm service that extends from the libraries typeorm service, but that only overrides the update / create methods, the get methods are all inherited. We are using Microsoft SQL Server 2019 |
This is the resolvers definition: resolvers: [
{
DTOClass: LineDto,
UpdateDTOClass: UpdateLineDto,
ServiceClass: LinesRelationQueryService,
EntityClass: Line,
enableAggregate: true,
delete: { disabled: true },
create: { disabled: true },
guards,
},
] The DTO: export class LineDto extends ResourceDto {
@FilterableField(() => Int)
lineVersion: number;
@FilterableField({ nullable: false })
pending: boolean;
...
} |
I think the reason for this change was to support grouping by week/day/month, commit: 7ffeaf6, we can check to update this to the old behaviour for non date fields. |
@Flusinerd would it be possible for you to tryout something? Could you update |
Hi, ty for coming back to this. I'll give it a try on Monday 😉 |
Sorry after checking a bit more the change is not going to make a difference. I do now see the change what caused it, when implementing the grouping of dates (DAY, WEEK etc) we also changed how the group by is done so that it references the alias and we only needed the date logic on one place. The fix could be that we just update that logic to not use the alias if the field is not a date field, but than the grouping of dates will not work for SQL server, or we update the complete logic to instead of using the alias for date and normal fields we use the normal fields and the query of the date for date fields as group by, this will than work for all languages. What do you think? |
Describe the bug
GroupBy does not work with aggregate queries, because of invalid column name, when using SQL-Server.
Have you read the Contributing Guidelines?
Yes
To Reproduce
Steps to reproduce the behavior:
groupBy
set to fields of the DTOGROUP BY
clauses.Expected behavior
Aggregate query should not fail.
It should use the column name instead of the alias.
Screenshots
Desktop (please complete the following information):
Additional context
GraphQL Query:
NestJS Exception:
Generated SQL:
SQL that works:
The text was updated successfully, but these errors were encountered: