#27985: Converting `Foo.objects.filter(bar=None)` to an `IsNull` too early.
-------------------------------------+-------------------------------------
     Reporter:  Jarek Glowacki       |                    Owner:  Sergey
                                     |  Fedoseev
         Type:  Bug                  |                   Status:  closed
    Component:  Database layer       |                  Version:  master
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:  fixed
     Keywords:  sql None NULL        |             Triage Stage:  Accepted
  transform                          |
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by Simon Charette):

 > Please don't feel the need to add a workaround or hack for my project.
 Now that it is identified, I'm happy to fix my buggy code to rely only on
 defined behavior.
 >
 > Or are you suggesting that in a future version of Django, `RelatedExact`
 raise an exception when used with an unsaved object?

 While it was undefined I'm kind of shocked we didn't have any tests for
 this. I'm not sure if you added this test on purpose in your suite but I
 could see it happening often in cases where users mix ''model factories''
 with the ORM in tests.

 I feel like preventing unsaved objects from being used in all related
 filters in future versions of Django would be the best course of action
 here. Surprisingly erroring on `if value._state.adding` in
 
[https://github.com/django/django/blob/master/django/db/models/fields/related_lookups.py#L28
 get_normalized_values] yields quite a few test failures in the suite.
 Nothing that looks unsolvable though.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/27985#comment:14>
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 unsubscribe from this group and stop receiving emails from it, send an email 
to django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/065.e2bec5bed5d010dfae9a555f9ecc7b90%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to