-
-
Notifications
You must be signed in to change notification settings - Fork 547
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
find_with_related
implicitly adds ordering on left.id
#2220
Comments
SelectTwoMany
forces ordering by id
find_with_related
implicitly adds ordering by left.id
find_with_related
implicitly adds ordering by left.id
find_with_related
implicitly adds ordering on left.id
in the past, the consolidator needs the query results to be ordered. this constrait was dropped in #1743 but the behaviour has not changed. removing the default order by is a break I want to avoid, but I agree users should be given the preference if they want to override the ordering |
That makes sense. I think just calling attention in documentation to the fact that The workaround I noted (placing the |
I totally agree with you, would appreciate if you can make a PR on any of the points above |
Description
find_with_related
implicitly adds anorder by
on the left table's id. This is extremely unintuitive; for instance:generates a query that is ordered by
(LeftId, LeftCol1, LeftCol2)
rather than(LeftCol1, LeftCol2)
, as might be expected.Steps to Reproduce
find_with_related
that includes anorder_by
after thefind_with_related
.build(..).to_string()
itorder by left.id asc
prepended to itExpected Behavior
In the example case from the description, I would expect the ordering to be
(LeftCol1, LeftCol2)
.Actual Behavior
In the example case from the description, the actual ordering is
(LeftId, LeftCol1, LeftCol2)
.Reproduces How Often
Deterministically.
Workarounds
Placing the
order_by
before thefind_with_related
, like so:produces an ordering on
(LeftCol1, LeftCol2, LeftId)
, which is acceptable. However, the fact that the query needs to be constructed in this manner is very non-obvious.Reproducible Example
See description
Versions
The text was updated successfully, but these errors were encountered: