Skip to content
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

Order by DESC clause works incorrectly for multiple fields #2

Closed
Seblink opened this issue Sep 28, 2021 · 1 comment
Closed

Order by DESC clause works incorrectly for multiple fields #2

Seblink opened this issue Sep 28, 2021 · 1 comment

Comments

@Seblink
Copy link

Seblink commented Sep 28, 2021

There is a bug in the code when you try to order by multiple fields in a descending fashion. Only the last field is ordered descending, the other fields are ordered ascending.

The following code xx.orderByDesc( field1, field2 ).build(); results in the generation of the following query: ORDER BY { field1 },{ field2 } DESC. This is interpreted as ORDER BY { field1 } ASC ,{ field2 } DESC by the SQL specification because ASC is the default ordering.

One would expect that the generated code would be ORDER BY { field1 } DESC, { field2 } DESC based on the name of the method in the flexible search builder.

Ideally, the ordering would be revised so one can specificy multiple fields, and for every field separatly one can specify either ASC/DESC.

@avrilfanomar
Copy link
Owner

@Seblink thanks for reporting this!
Probably the better syntax would be like x.orderByDesc(field1).orderByAsc(field2).
I'll try to get my hands on it.

avrilfanomar pushed a commit that referenced this issue Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants