-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
MSSQL - strange behavior with limit and already specified order #14185
Comments
That's weird. The only line in mssql's query generator that mutates the order option is this one https://github.com/sequelize/sequelize/blob/main/src/dialects/mssql/query-generator.js#L881 |
Hi @ephys 馃憢, thank you for your response. You are right, In fact it add to the existing query , [city].[id] OFFSET 0 ROWS FETCH NEXT 5 ROWS ONLY; So I'm try to understand why this If we look Let me know 馃榿 |
Aah, sorry I went too fast again and didn't read carefully enough I remember seeing the weird behavior in that function too, I added the comment just before it
Maybe mssql had (has?) a requirement to specify Anyway, it seems the reason the clause is added is because this piece of code did not expect |
You are right, and I just tested it mssql need an |
Issue Creation Checklist
Issue Description
Hi guys 馃憢, I just want to confirm with you if I found a bug or if I just do something wrong.
Let's say I have 2 models defined like this:
I have this findAll query 馃憞, the goal is pretty simple, I just want to make a leaderboard by the most used
city
inaddresses
.This is where you can help me determine if it's a bug or if I did something wrong.
The call to the findAll function result to this query 馃憞
In fact this query result to a SQL error that say:
Column "city.id" is invalid in the ORDER BY clause because it is not contained in either an aggregate function or the GROUP BY clause.
I deep dive in the code and I found something strange here
sequelize/src/dialects/mssql/query-generator.js
Lines 993 to 1006 in abdb896
Sorry about the long message, but my question is: Why [city].[id] is added if I specify an order in my query?
let me know if it not clearer enough.
Thank's for your time 馃檹 have a great day.
Issue Template Checklist
Is this issue dialect-specific?
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: