#31486: Related filters with unsaved objects
-------------------------------------+-------------------------------------
               Reporter:  Mapiarz    |          Owner:  nobody
                   Type:             |         Status:  new
  Uncategorized                      |
              Component:  Database   |        Version:  2.2
  layer (models, ORM)                |
               Severity:  Normal     |       Keywords:
           Triage Stage:             |      Has patch:  0
  Unreviewed                         |
    Needs documentation:  0          |    Needs tests:  0
Patch needs improvement:  0          |  Easy pickings:  0
                  UI/UX:  0          |
-------------------------------------+-------------------------------------
 Consider this filter:
 {{{
 Foo.objects.filter(related_obj=bar)
 }}}
 Where 'bar' is an unsaved object instance. In Django 1.11, this would
 always return an empty QuerySet (since no Foo object is related to unsaved
 'bar'). In Django 2.0 through 2.2, this is equivalent to doing (which can
 return a non-empty QuerySet):
 {{{
 Foo.objects.filter(related_obj=None)
 }}}

 I found a somewhat related issue that touches on this subject:
 https://code.djangoproject.com/ticket/27985

 My questions:
 1. What is the intended behaviour? In the aforementioned issue Simon
 Charette suggests that unsaved objects should be prevented from being used
 in related filters. I agree with that.
 2. Is this documented anywhere? I couldn't find anything. At the very
 least this should be documented somewhere.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31486>
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.230ad1e499ca8126f4aa90e88121618b%40djangoproject.com.

Reply via email to