-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Support for 'is null' in 'order by' (#3667) #4720
Conversation
OlivierCavadenti
commented
Oct 10, 2021
•
edited
edited
- Attempt to resolve issue Support for 'is null' in 'order by' #3667
- add support to order nulls in order by with 'first' and 'last' option.
- 'first' add 'is not null' in order by clause (=> put nulls in first position)
- 'last' add 'is null' in order by clause (=> put nulls in last position)
- add support to order nulls in order by with 'first' and 'last' option.
table.increments('id').primary(); | ||
table.string('null_col').nullable().defaultTo(null); | ||
}) | ||
.then(function () { |
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.
could you please rewrite this to use async/await?
TS types need to be updated, and we also need documentation updated for this. |
I update index.d.ts and rework a test but it seems 'is null' is not valid in mssql: RequestError: select [id] from [OrderByNullTest] order by ([null_col] is not null) asc - Incorrect syntax near the keyword 'is'. I need to investigate |
@OlivierCavadenti It appears that MSSQL doesn't support that, and one would need to implement hacks to get that working: https://stackoverflow.com/questions/5886857/sql-server-order-by-date-and-nulls-last If you feel like implementing custom solution to get that working with MSSQL, that would be great, but if that's too much work, throwing an error when trying to use that param on MSSQL is also sufficient. |
I will see what I can do to get that working with MSSQL. Thanks for the link. |
Thanks a lot! Can you also add documentation for this? |