-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Query Builder Class - orderBy more possibilities #6716
Comments
Cases like this are already supported: $builder->orderBy('year IS NULL', '', false)->orderBy('year', 'asc'); |
Yes, but if
Behavior is ambiguous... |
@michalsn Thank you. Exactly! $builder = new BaseBuilder('paintings', $this->db);
$builder->orderBy('year IS NULL', '', false)->orderBy('year', 'asc');
|
'IS NULL' is expected to have the same behavior as 'ASC' or 'DESC', but is produced differently. If fix this line in the system/Database/BaseBuilder.php file:
and
on those
and
then everything starts working. |
I don't think allowing the If you change your DB engine to SQLSRV, your query will fail. |
Well, maybe then add the modified |
This syntax is not supported by QueryBuilder, because all the supported DBMS do not support it. |
In general, we don't accept features that would have support in only one DB engine. And allowing different valid What would make sense is building some kind of abstraction like we did for the For cases like yours, we have a third parameter in |
This is wrong. The way it works and is documented is: ORDER BY [EXPRESSION] [DIRECTION] I would do it like: ORDER BY IF(year IS NULL, 0, 1) ASC This should be closed. |
I want to execute a query using Query Builder Class:
SELECT * FROM paintings ORDER BY year IS NOT NULL, year ASC;
or
SELECT * FROM paintings ORDER BY year IS NULL, year ASC;
but Query Builder Class does not support this:
$builder->orderBy('year IS NULL, year ASC');
Please add this feature in future releases.
The text was updated successfully, but these errors were encountered: