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

Fix filterset multiple inheritance bug #1131

Merged

Conversation

rpkilby
Copy link
Collaborator

@rpkilby rpkilby commented Oct 9, 2019

Declared filter resolution was mostly copied from DRF. This fixes a multiple inheritance bug described in encode/django-rest-framework#6980

@codecov-io
Copy link

codecov-io commented Oct 9, 2019

Codecov Report

Merging #1131 into master will increase coverage by 1.33%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1131      +/-   ##
==========================================
+ Coverage    98.1%   99.44%   +1.33%     
==========================================
  Files          15       15              
  Lines        1216     1255      +39     
==========================================
+ Hits         1193     1248      +55     
+ Misses         23        7      -16
Impacted Files Coverage Δ
django_filters/filterset.py 100% <100%> (ø) ⬆️
django_filters/utils.py 100% <0%> (ø) ⬆️
django_filters/rest_framework/filterset.py 100% <0%> (ø) ⬆️
django_filters/filters.py 100% <0%> (+0.29%) ⬆️
django_filters/conf.py 100% <0%> (+2.94%) ⬆️
django_filters/widgets.py 100% <0%> (+4.72%) ⬆️
django_filters/rest_framework/backends.py 100% <0%> (+8.53%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update da4b64e...f7e7af3. Read the comment docs.

@carltongibson
Copy link
Owner

We sure we’re not changing a behaviour from the dawn of time here? 🙂

@rpkilby
Copy link
Collaborator Author

rpkilby commented Oct 9, 2019

It looks like the original behavior was mirrored in this PR.

if with_base_filters:
for base in bases[::-1]:
if hasattr(base, 'base_filters'):
filters = list(base.base_filters.items()) + filters
else:
for base in bases[::-1]:
if hasattr(base, 'declared_filters'):
filters = list(base.declared_filters.items()) + filters

However, I refactored get_declared_filters at some point and iirc I copied the code largely from DRF. Currently looking into this.

@rpkilby
Copy link
Collaborator Author

rpkilby commented Oct 9, 2019

oh wait, I read that completely wrong. 🤦‍♂

Either way, like DRF, I think the test case demonstrates that the current behavior is incorrect. I just don't think this multiple inheritance use case is incredibly common, which is why it hasn't been raised here yet (and why it hasn't seen much attention in DRF either).

@carltongibson
Copy link
Owner

OK... Let me look into it. I want to be 100% sure. (And we'll need a release note stating the BC change.)

@rpkilby
Copy link
Collaborator Author

rpkilby commented Nov 1, 2019

Just as a note, this PR needs to be updated, pending review of the DRF PR.

@rpkilby rpkilby changed the title Fix filterset multiple inheritance bug [wip] Fix filterset multiple inheritance bug Nov 1, 2019
@rpkilby rpkilby changed the title [wip] Fix filterset multiple inheritance bug Fix filterset multiple inheritance bug Mar 4, 2020
@rpkilby
Copy link
Collaborator Author

rpkilby commented Mar 4, 2020

@carltongibson updated this from the DRF pr. This should be good to go assuming tests pass.

Copy link
Owner

@carltongibson carltongibson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super, yes. Good work!

@carltongibson carltongibson merged commit 6251bb5 into carltongibson:master Mar 4, 2020
@rpkilby rpkilby deleted the fix-filterset-multiple-inheritance branch March 4, 2020 19:52
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.

None yet

3 participants