-
Notifications
You must be signed in to change notification settings - Fork 766
Fix select_related with filtering #224
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
Conversation
4 similar comments
bdc7189
to
f93251b
Compare
@syrusakbary Same fix as #194, just specific to filter fields. Looks fine to me. |
Hi, IMO this code violates DRY principle and should be refactorized. The DjangoFilterConnectionField is inherited from DjangoConnectionField where the code is ok (in classmethod merge_queryset). I agree with this fix (it's the same fix as mine in duplicate #272 ) but I think it is definitely not a good final solution. |
Thanks for accepting the fix! I'm not able to merge it, so I'll leave that to the project collaborators. Thanks everyone. :) |
I agree with @jancespivo that the code needs to be refactored, but we can do it in a separate PR. The change looks good, but I think before merging the PR should include tests ensuring that the issue is not repeated in future releases. |
Now that the failing test in master is fixed, this PR is ✅. @syrusakbary Ready for merge, and I can close several duplicate issues/PRs for this bug. |
2 similar comments
Thanks for the merge! :) |
There's an issue with this merge - if a class is subclassing other people fixed this issue by copying the code from the merge_queryset but it seems we can keep this change and have only one place for that code by replacing |
Travis was failing on the original pyup-bot PRs, since the updates need to all be made at once. The `DjangoFilterConnectionField` workaround has been removed, since it should no longer required, as the new release includes: graphql-python/graphene-django#224 Release notes: * https://github.com/graphql-python/graphql-core/releases/tag/v2.1.0 * https://github.com/graphql-python/graphene/releases/tag/v2.1.3 * https://github.com/graphql-python/graphene-django/releases/tag/v2.1rc0 * https://github.com/graphql-python/graphene-django/releases/tag/v2.1rc1 * https://github.com/graphql-python/graphene-django/releases/tag/v2.1.0 Closes #3806. Closes #3807. Closes #3808.
Travis was failing on the original pyup-bot PRs, since the updates need to all be made at once. The `DjangoFilterConnectionField` workaround has been removed, since it should no longer required, as the new release includes: graphql-python/graphene-django#224 Release notes: * https://github.com/graphql-python/graphql-core/releases/tag/v2.1.0 * https://github.com/graphql-python/graphene/releases/tag/v2.1.3 * https://github.com/graphql-python/graphene-django/releases/tag/v2.1rc0 * https://github.com/graphql-python/graphene-django/releases/tag/v2.1rc1 * https://github.com/graphql-python/graphene-django/releases/tag/v2.1.0 Closes #3806. Closes #3807. Closes #3808.
I must admit, I don't totally see the need for this union between the
default_queryset
andqueryset
but through experimentation, I have found that if the order of the union is reversed, it will preserve theselect_related
andprefetch_related
. It has the same effect of finding the union of records returned. The list is identical.So I hope this change doesn't break something I'm not aware of. :)
This is an attempt to fix #179