-
Notifications
You must be signed in to change notification settings - Fork 308
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 with distinct generates wrong query #318
Comments
Sample 1 and Sample 2 behaviours are documented - and therefore I would not change it. Sample 3 is the correct way to go about things, if you want to enforce both order by and distinct - but we need to remove the duplicate. |
It seems non obvious to me that on Sample 2 we ignore distinct sorting option if |
The But we now have to repeat both the columns and the sort orders, which is unexpected. Maybe this should be allowed? Current behaviorfrom(i in Import, distinct: [desc: i.id], order_by: []) |> Repo.all generates SELECT DISTINCT ON (i0."id") i0."id", i0."inserted_at", i0."updated_at" FROM "imports" AS i0 Expected behaviorwould generate SELECT DISTINCT ON (i0."id") i0."id", i0."inserted_at", i0."updated_at" FROM "imports" AS i0 ORDER BY i0."id" DESC |
Environment
elixir:1.11.2-alpine
postgres:13.1-alpine
3.5.5
postgres 0.15.8
linux alpine
Sample 1
Current behavior
generates
Expected behavior
would generate
Sample 2
Current behavior
generates
Expected behavior
would generate
Sample 3
Current behavior
generates
Expected behavior
would generate
would generate section contains the same query in every example
The text was updated successfully, but these errors were encountered: