-
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 + distinct builds wrong query #35
Comments
Actually I have a working fix at: elixir-ecto/ecto#2810 |
Since 2.2 ecto supports adding For example: queryable
|> distinct([desc: :begin_at, desc: :id]) |
Amended my PR to prefer ordering from distinct as suggested above. |
@fenollp what @michalmuskala meant is that this is working as expected. The solution is not to duplicate the order by and the distinct, is to use Does it make sense? |
Ah I get it now. Indeed this works fine! Thanks |
Environment
PG_VERSION=9.6.6
OSX 10.14.1
Current behavior
This code:
generates the following request:
Expected behavior
It appears there is a difference between these two way of writing the
order_by()s
.See elixir-ecto/ecto#504 for initial discussion on distinct_on+order_by.
See elixir-ecto/ecto#1669 for what seems to be a very similar bug report.
Note that I explicitly
select distinct
order_by fields to avoidCurrent workaround:
EDIT: I haven't tried ecto_sql v3 but code in connection.sql looks similiar enough.
The text was updated successfully, but these errors were encountered: