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
fix: use aliases if subQuery is not used (v7) #14882
Conversation
We're talking about this test right? sequelize/test/unit/sql/select.test.js Lines 196 to 242 in 3cc8c5e
We've added this test in #6560 and @ephys worked on this in #13985 (she added the TODO in the mssql query-generator). |
I do wonder why MSSQL requires so much work as well. I wonder if it's worth a larger look |
I think it is, but after we have migrated it to TypeScript (possibly even after the first release of v7). We'll probably also notice some things during that conversion and having stricter typing will probably help us as well |
give this input and the fact that we might want to refactor mssql once ts migration is completed, I'd say this PR is good to go. It's a but ugly but should roughly work |
Approved since we have consensus about cleaning up later - thanks for picking this up @sdepold! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two comments of possible additional tests and one question. But I like the new function
@WikiRik @evanrittenhouse Ready maybe :) |
Sooo. Without casting the primaryKey to Col:
With casting primaryKey to Col:
is it supposed to make any difference? |
I wasn't sure, but now we know the query does not change we should be good to remove it. Thanks for checking it out! |
@WikiRik do you think we should remove the col casting in v6 too? |
No, let's leave it for now |
🎉 This PR is included in version 7.0.0-alpha.16 🎉 The release is available on: Your semantic-release bot 📦🚀 |
backport of #14852
please note that particularly the second commit is very odd since it's unclear to me why we are doing so much additional manual work for mssql.
during my attempts on refactoring I stumbled across this test code:
Please note the order by instructions which imho order the results twice based on the same property. (subqueryorder0 === id_user)
Similarly I was wondering for other query where we order by lastName first and userId second, why we even automatically add an order by primaryKey in the first place. I get it if you don't have any order in place, but if the user decides to sort by last name, why would we adjust this to order by the pk secondarily?