#15316: Filter with isnull=False failing when isnull checked on subclass of FK
model
-------------------------------------+-------------------------------------
Reporter: zimnyx | Owner: nobody
Type: Bug | Status: new
Milestone: | Component: Database layer
Version: SVN | (models, ORM)
Resolution: | Severity: Normal
Triage Stage: Accepted | Keywords:
Needs documentation: 0 | Has patch: 1
Patch needs improvement: 1 | Needs tests: 0
UI/UX: 0 | Easy pickings: 0
-------------------------------------+-------------------------------------
Changes (by russellm):
* needs_better_patch: 0 => 1
Comment:
Looks good to me -- I'd like to see a couple of minor fixes before marking
it RFC.
The current if statement checks "value is True" and "not negate" as two
separate checks; the patch adds a test to make sure that the "value is
True" part isn't actually required, but doesn't validate that it also
isn't required for the negation case. There are essentially 4 cases that
need to be tested:
* filter(isnull=True)
* exclude(isnull=True)
* filter(isnull=False)
* exclude(isnull=False)
It's entirely possible that some of these cases might be checked
elsewhere, but it doesn't hurt to validate all four just to be certain.
It would also be good to validate at a stronger level than count -- for
example, if you get the joins wrong, it's possible that you might be
validating the existence of a DumbCategory rather than a NamedCategory. It
would be better to validate against something that clearly identified that
the right CategoryItem object was being returned, rather than just
validating that only 1 instance is returned.
Lastly, I think two nasty ORM bugs is enough to earn you a line in the
AUTHORS file :-) Feel free to include that change in the updated patch,
too.
--
Ticket URL: <https://code.djangoproject.com/ticket/15316#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en.