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

Warn when applying ordering to a query with pre-existing order #524

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

tomekowal
Copy link

@tomekowal tomekowal commented Dec 7, 2024

Hey!

This PR attempts to mitigate issue #522
I was thinking about removing the pre-existing order_by from queries, but Ecto docs mention that reading the internal structure of the query is somewhat OK, but modifying is a no go.

https://hexdocs.pm/ecto/Ecto.Query.html#__struct__/0

Users of Ecto must consider this struct as opaque and not access its field directly. Authors of adapters may read its contents, but never modify them.

Flop is not exactly an adapter, but I think similar logic applies.

Using the internal API of Ecto seems to me as a good trade for avoiding the confusion of accidentally passing a query with pre-existing order_by which leads to a very weird behaviour and a lot of confusion.

We could potentially be more strict and even raise when we have a query with pre-existing order_by, but that would be a breaking change.

Let me know what you think, I am happy to make any corrections you find necessary.

@tomekowal tomekowal requested a review from woylie as a code owner December 7, 2024 08:53
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

Successfully merging this pull request may close these issues.

1 participant