#26379: Inconsistent behaviour of filter() on related model (RelatedManager)
-------------------------------------+-------------------------------------
     Reporter:  ignus2               |                    Owner:  nobody
         Type:  Bug                  |                   Status:  new
    Component:  Database layer       |                  Version:  1.9
  (models, ORM)                      |
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:  Accepted
    Has patch:  0                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------

Comment (by ignus2):

 Which query? The first one? It shouldn't give you any results, as this
 clause in the first set of queries:
 {{{
 ("testapp_subscription"."blog_id" = 1 AND
 "testapp_subscription"."subscribed_date" > 2016-01-15)
 }}}
 cannot be true (there is only one subscription for "Blog 1", and that is
 on 2016-01-10).

 I also tested the query directly in SQLite, and it seems the SQLite
 command line program is buggy or something, as it also gave me a result,
 however when I put quotes around the date above : "2016-01-15", like this:
 {{{
 SELECT "testapp_person"."id", "testapp_person"."name" FROM
 "testapp_person" INNER JOIN "testapp_subscription" ON
 ("testapp_person"."id" = "testapp_subscription"."person_id") WHERE
 ("testapp_subscription"."blog_id" = 1 AND
 "testapp_subscription"."subscribed_date" > "2016-01-15")
 }}}
 then it correctly didn't give any results. What is incorrect here is the
 query string itself, the second set of queries in the original bug
 description are the correct ones!

 About the date quotes:
 We just might have found another unrelated bug here, namely the quotation
 around the date, I assume Django is using placeholders internally not the
 above string literally, but when it generates the string for us to read,
 it fails to put quotation marks around the date, though I don't know
 whether that would be correct (or it's simply an SQLite command line bug).

 Replying to [comment:3 AmineYaiche]:
 > Certainly a bug.
 >
 > What's weird about this is that the SQL query is correct. When i've
 executed the query in a DBMS it gave me "adam" in the result, while the
 filter() method gives an empty queryset.

--
Ticket URL: <https://code.djangoproject.com/ticket/26379#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 unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.37dd578277e44af8b27afe82719c5dd9%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to