-
Notifications
You must be signed in to change notification settings - Fork 99
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
#78 order by of a has many through not respected #144
#78 order by of a has many through not respected #144
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Please run mix format
and then we should be good to go.
@@ -672,7 +672,7 @@ if Code.ensure_loaded?(Ecto) do | |||
records = records |> Enum.map(&Map.put(&1, field, empty)) | |||
|
|||
results = | |||
if query.limit || query.offset do | |||
if query.limit || query.offset || Enum.any?(query.order_bys) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting! So is the reason that this is required is because it can have a separate ordering from the overall query? I'm curious about the performance implications of this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be completely honest, I don't really know.
Last night was my first time reading this code. I was encountering the bug in my side-project.
I just saw that this if
expression was a critical branching point. My has_many...through...order_by
expressions were being swallowed by repo.preload
and lost somewhere in there. So I decided to try to make them got through the lateral_preload
path. When it fixed my problem, and no other tests were failing, I opened the PR.
While I'm being completely honest, I should say that all the tests pass even if I write
raise "This path is not tested"
where the repo.preload
call is (the negative case of the if
expression).
So that flow is completely untested.
I ran mix format and nothing changed. I am using elixir 1.13, as per the |
Ah ok, I'll merge and then handle in master. Thanks! |
…by-of-a-has-many-through-not-respected absinthe-graphql#78 order by of a has many through not respected
Coming back to this way after the fact: One thing that is odd now is that if you specify |
Yes I knew this would be the case. At the time I thought "better to be slow and reliable than fast and unreliable".
Can you write or at least envision a failing test to demonstrate this? |
Updated our project to use the latest dataloader and now we have many preloading coming empty of things being dataloaded. After some debugging, it appears that it's because of this change which forces the loads of many things through lateral option. Trying to understand why the preloads are not working at all as soon as the query is ordered, it appears that the code that test for the existence of preloads in the query somehow does not work... The
The test on |
It is likely we're going to have to revert this commit for a few reasons.
We have been using https://github.com/absinthe-graphql/dataloader/tree/remove-undesirable-lateral for a while now internally. Notably, for
with
And then when you specify an order on the |
I believe this fixes #78