Re: [Django] #13937: Sub-query (exclude) fails when joining

2013-08-19 Thread Django
#13937: Sub-query (exclude) fails when joining
-+-
 Reporter:  subsume  |Owner:
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.2
  (models, ORM)  |   Resolution:  fixed
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:   |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  0|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by akaariai):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 This is fixed in master, the generated query is:
 {{{
 SELECT "queries_consumer"."id", "queries_consumer"."race" FROM
 "queries_consumer" WHERE ("queries_consumer"."race" = PWI Approved  AND
 NOT ("queries_consumer"."id" IN (SELECT U1."consumer_id" FROM
 "queries_contact" U1 WHERE (U1."date" BETWEEN 2010-05-03 and 2010-05-04
 AND U1."consumer_id" IS NOT NULL
 }}}

 I will close this without adding tests, I am pretty confident that similar
 conditions are already tested in master.

-- 
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/065.8af9ab8c263883a2405b15a631042666%40djangoproject.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [Django] #13937: Sub-query (exclude) fails when joining

2011-09-08 Thread Django
#13937: Sub-query (exclude) fails when joining
-+-
   Reporter:  subsume|  Owner:
   Type:  Bug| Status:  new
  Milestone: |  Component:  Database layer
Version:  1.2|  (models, ORM)
 Resolution: |   Severity:  Normal
   Triage Stage:  Accepted   |   Keywords:
Needs documentation:  0  |  Has patch:  0
Patch needs improvement:  0  |Needs tests:  0
  UI/UX:  0  |  Easy pickings:  0
-+-
Changes (by PhiR):

 * ui_ux:   => 0
 * easy:   => 0


Comment:

 I've just added a patch to #12823 which fixes a similar bug. Could you
 possibly check if the bug still happens ? It seems to work for me but
 YMMV...

-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13937: Sub-query (exclude) fails when joining

2011-04-01 Thread Django
#13937: Sub-query (exclude) fails when joining
-+-
   Reporter:  subsume|Owner:
   Type:  Bug|   Status:  new
  Milestone: |Component:  Database layer
Version:  1.2|  (models, ORM)
 Resolution: | Severity:  Normal
   Triage Stage:  Accepted   | Keywords:
Needs documentation:  0  |Has patch:  0
Patch needs improvement:  0  |  Needs tests:  0
-+-
Changes (by graham_king):

 * type:   => Bug
 * severity:   => Normal


-- 
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13937: Sub-query (exclude) fails when joining

2010-12-28 Thread Django
#13937: Sub-query (exclude) fails when joining
---+
  Reporter:  subsume   | Owner: 
Status:  new   | Milestone: 
 Component:  Database layer (models, ORM)  |   Version:  1.2
Resolution:|  Keywords: 
 Stage:  Accepted  | Has_patch:  0  
Needs_docs:  0 |   Needs_tests:  0  
Needs_better_patch:  0 |  
---+
Changes (by russellm):

  * stage:  Unreviewed => Accepted

Comment:

 For posterity, the full set of models are:
 {{{
 class Consumer(models.Model):
 race = models.CharField(max_length=100)

 class Contact(models.Model):
 consumer = models.ForeignKey(Consumer,null=True,blank=True)
 date = models.DateField()
 }}}

 The IS NULL clause is being added because the foreign key is nullable, so
 the query engine is making sure that you aren't joining on a Contact entry
 that has a date in range, but has no related Consumer. However, it seems
 to be picking the wrong table alias (using the base table, instead of U1).

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13937: Sub-query (exclude) fails when joining

2010-11-14 Thread Django
#13937: Sub-query (exclude) fails when joining
---+
  Reporter:  subsume   | Owner: 
Status:  new   | Milestone: 
 Component:  Database layer (models, ORM)  |   Version:  1.2
Resolution:|  Keywords: 
 Stage:  Unreviewed| Has_patch:  0  
Needs_docs:  0 |   Needs_tests:  0  
Needs_better_patch:  0 |  
---+
Changes (by k0001):

  * owner:  k0001 =>

Comment:

 Could you tell a bit more about your scenario? Please provide some sample
 models, your expected results and your actual results.

 Appart from —needlessly? I'm not sure— checking if the Primary Key is not
 null, I wonder why would this fail for you.

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13937: Sub-query (exclude) fails when joining

2010-11-13 Thread Django
#13937: Sub-query (exclude) fails when joining
---+
  Reporter:  subsume   | Owner:  k0001
Status:  new   | Milestone:   
 Component:  Database layer (models, ORM)  |   Version:  1.2  
Resolution:|  Keywords:   
 Stage:  Unreviewed| Has_patch:  0
Needs_docs:  0 |   Needs_tests:  0
Needs_better_patch:  0 |  
---+
Changes (by k0001):

  * owner:  nobody => k0001

Comment:

 I'm checking this right now.

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13937: Sub-query (exclude) fails when joining

2010-11-13 Thread Django
#13937: Sub-query (exclude) fails when joining
---+
  Reporter:  subsume   | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  1.2   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Comment (by Daishiman):

 Can you provide a sample models.py file to test it in other backends?

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



Re: [Django] #13937: Sub-query (exclude) fails when joining

2010-07-14 Thread Django
#13937: Sub-query (exclude) fails when joining
---+
  Reporter:  subsume   | Owner:  nobody
Status:  new   | Milestone:
 Component:  Database layer (models, ORM)  |   Version:  1.2   
Resolution:|  Keywords:
 Stage:  Unreviewed| Has_patch:  0 
Needs_docs:  0 |   Needs_tests:  0 
Needs_better_patch:  0 |  
---+
Changes (by subsume):

  * needs_better_patch:  => 0
  * needs_tests:  => 0
  * needs_docs:  => 0

Comment:

 I got my examples mixed up there. pwi_status__name='wtvr' should be
 race='american'

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.



[Django] #13937: Sub-query (exclude) fails when joining

2010-07-14 Thread Django
#13937: Sub-query (exclude) fails when joining
--+-
 Reporter:  subsume   |   Owner:  nobody
   Status:  new   |   Milestone:
Component:  Database layer (models, ORM)  | Version:  1.2   
 Keywords:|   Stage:  Unreviewed
Has_patch:  0 |  
--+-
 I have a suprisingly simple-looking query that fails in 1.2 using MySQL:

 {{{
Consumer.objects.filter(pwi__status__name='PWI
 Approved').exclude(contact__date__range=('2010-05-03','2010-05-04'))
 }}}

 This produces some suspicious SQL:

 {{{

SELECT * FROM `consumer_consumer`
WHERE (`consumer_consumer`.`race` = %s
   AND NOT ((`consumer_consumer`.`id`
  IN (
   SELECT U1.`consumer_id` FROM `base_contact` U1
  WHERE U1.`date` BETWEEN %s and %s
  ) AND NOT (`consumer_consumer`.`id` IS NULL

 }}}

 Take a look at this last line. I'm not sure what mechanism is adding this
 line, however, there is some wisdom in it because if this is transposed
 into the sub-query ("AND NOT UI.consumer_id IS NULL"), we have a perfectly
 functioning query. I can't imagine why we would want to make sure our
 model's primary key isn't null.

 the Consumer model is rather boring, the contact model goes:

 class Contact(models.Model):
consumer = models.ForeignKey('consumer.Consumer,null=True,blank=True)

-- 
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 post to this group, send email to django-upda...@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.