-
-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Fixed #3674 -- Refactored _get_reverse_relationships() to use correct to_field #3696
Conversation
…eld instead of current object's
I'm not at all sure this is the correct or best fix. Had a little trouble wrapping my head around everything that's going on as these parameters get passed around, so I don't know if this patch will adversely affect any existing behaviour. |
Okay seems valid - able to provide a test case to demonstrate the issue/fix? |
I really have doubts about this. |
I just realize we may need a test case with a non PK relation here (not directly related to the issue here though linked to). |
@xordoquy: That's essentially what I was worried about. I'm going to try and get a decent test set up and I'll work on making the fix less restrictive at the same time. |
@benred42 let me know about your progress on this. |
…ship is reverse vs forward to ensure correct field checking
Still working on the test, but here's what I have so far for a modified fix. I figured the real issue was actually in EDIT: I can already see that I need to modify the fix so it will work on 1.9 |
@benred42 no worries :) |
Okay, the fix works on Django1.9 now and I have an initial test in. Looks like more test coverage is needed on the patch, however. |
Not sure how codecov does work here, doesn't seem to point to the right commits... |
Milestoning this issue to keep it on our radars. |
I think we should probably turn off the patch-level coverage threshold. |
Okay - I've turned off the patch-level threshold. |
I feel like the test could use some work. Right now it does fail without the fix and passes with it, but it seems like it should be more directly testing the issue instead of making a tangential assertion that will cause an exception to be raised if the issue is present. I could also just be being too picky. |
Okay, so I refactored the test and I feel it is a better test now, but I'm not sure how consistent it is with the way the existing tests are set up, so I figured I'd paste it here and get feedback on it before pushing it up: http://dpaste.com/0DGMJ18 |
Fixed #3674.
Changed
_get_reverse_relationships()
inmodel_meta.py
to use the pk of the related object instead of the current object's pk when assigningto_field
. This corrected an issue inserializers.py
wherebuild_relational_field()
would try to call_meta.get_field()
in django with the wrong field.