-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Schema preload_order
cannot be overriden by passing ordered query
#4535
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
Comments
I think you could argue for both behaviours. And that's exactly the issue with these "default" values: at some point you end-up wanting to customize them, and now you need to provide mechanisms to undo the defaults. Lost of information could be equally confusing. :( It partially feels the best course of action here is to remove |
Indeed, but to be fair in this case the mechanism already exists, in the sense that preloading using an ordered query is already in the absence of a default.
I agree in more complex cases involving query composition this could happen, but given that the "normal way" of preloading using the default is that simple (
In my case this works indeed, so this is not a blocker. But I figured it would be nice to at least open an issue for the visibility in case somebody else ends up here, even if we keep the status quo 🙂 |
I am thinking for this one, we should apply our order, but it should come later. It probably doesn't make sense to override the user supplied one. |
@josevalim I'm not sure I understand your proposal, in the example above, would it mean In my mind, it makes sense to have a way to set sane default that you are able to overwrite, a bit like the Another way to look at this could be to say: if somebody tries to override the preload order set in the schema at the query level, instead of silently ignoring it, we could warn or raise to make it clear it's not doing anything? |
The opposite: |
Elixir version
Elixir 1.17.3 (compiled with Erlang/OTP 27)
Database and Version
PostgreSQL 17.0
Ecto Versions
ecto 3.12.4
Database Adapter and Versions (postgrex, myxql, etc)
postgrex 0.19.2
Current behavior
Expected behavior
I would have expected the
order_by
from the preload query (^from(c in Comment, order_by: [desc: :likes])]
) to take precedence over the schema orderingpreload_order: [asc: :likes]
.If however, it is not a bug but an expected feature, would it be possible to achieve this in some other way?
The text was updated successfully, but these errors were encountered: