Re: [Django] #21956: Inconsistent behaviour of Q objects

2014-02-05 Thread Django
#21956: Inconsistent behaviour of Q objects
-+-
 Reporter:  debanshuk|Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.5
  (models, ORM)  |   Resolution:  wontfix
 Severity:  Normal   | Triage Stage:
 Keywords:   |  Unreviewed
Has patch:  0|  Needs documentation:  0
  Needs tests:  0|  Patch needs improvement:  0
Easy pickings:  0|UI/UX:  0
-+-
Changes (by shai):

 * status:  new => closed
 * needs_better_patch:   => 0
 * resolution:   => wontfix
 * needs_tests:   => 0
 * needs_docs:   => 0


Comment:

 Per the documented [https://docs.djangoproject.com/en/1.6/internals
 /release-process/#supported-versions release process]:

   Committers may choose to backport bugfixes at their own discretion,
 provided they do not introduce backwards incompatibilities.

 This is a bugfix, not a security fix; a committer has considered
 backporting it, and decided against. The route to getting it backported
 nonetheless can go through two directions:

  * Go to [http://groups.google.com/group/django-developers the developers
 list] and argue your case there, and/or
  * Provide a patch against 1.5 yourself -- but be warned, without
 agreement on the list, there's a high chance of it getting rejected.

-- 
Ticket URL: 
Django 
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/067.eb92475a4f7340bf18b3e70f43ba44c6%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


[Django] #21956: Inconsistent behaviour of Q objects

2014-02-05 Thread Django
#21956: Inconsistent behaviour of Q objects
--+
 Reporter:  debanshuk |  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  Database layer (models, ORM)  |Version:  1.5
 Severity:  Normal|   Keywords:
 Triage Stage:  Unreviewed|  Has patch:  0
Easy pickings:  0 |  UI/UX:  0
--+
 Suppose we have a contact model with following definition:

 {{{
 class Contact(models.Model):
 name = models.CharField()
 company_uid = models.IntegerField(null=True, blank=True)
 }}}

 Consider following two queries:

 `Contact.objects.filter(~(Q(name='ABC') | Q(company_uid=5)))`
 `Contact.objects.filter(~Q(name='ABC') & ~Q(company_uid=5))`

 These queries are exactly the same, right? Just used DeMorgan's law i.e
 "not (A or B)" is the same as "(not A) and (not B)". But the generated SQL
 of these queries says something else:

 `SELECT "profiles_contact"."id", "profiles_contact"."name",
 "profiles_contact"."company_uid" FROM "profiles_contact" WHERE NOT
 (("profiles_contact"."name" = ABC  OR "profiles_contact"."company_uid" = 5
 ))`

 `SELECT "profiles_contact"."id", "profiles_contact"."name",
 "profiles_contact"."company_uid" FROM "profiles_contact" WHERE (NOT
 ("profiles_contact"."name" = ABC ) AND NOT
 (("profiles_contact"."company_uid" = 5  AND
 "profiles_contact"."company_uid" IS NOT NULL)))`


 (The desired query is the one with `IS NOT NULL` condition)


 This issue only exists till version 1.5, it has been fixed in Django-1.6.
 There is already a closed bug
 (https://code.djangoproject.com/ticket/21192) which was similar to this
 one. The bug was closed stating that the issue has been fixed in
 Django-1.6 and changes required to back-patch the fixes to 1.5 are just
 too big. But I believe this issue is more severe than the issue stated the
 that bug, as it is a more general case and should be back-patched to 1.5
 and older version too.

-- 
Ticket URL: 
Django 
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/052.d0b9f75d6e02e00f87033dc8de2407ee%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.