Re: [Django] #20250: AttributeError when filtering annotated queryset with negated Q (via fk)

2013-05-29 Thread Django
#20250: AttributeError when filtering annotated queryset with negated Q (via fk)
-+-
 Reporter:  jan.koutny@… |Owner:  Tim
 Type:  Bug  |  Graham 
Component:  Database layer   |   Status:  closed
  (models, ORM)  |  Version:  1.4
 Severity:  Normal   |   Resolution:  fixed
 Keywords:  annotate | Triage Stage:  Accepted
  AttributeError |  Needs documentation:  0
Has patch:  0|  Patch needs improvement:  0
  Needs tests:  1|UI/UX:  0
Easy pickings:  0|
-+-
Changes (by Tim Graham ):

 * owner:   => Tim Graham 
 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"7426e72302db9c8c78235afc5c335a437a7ad760"]:
 {{{
 #!CommitTicketReference repository=""
 revision="7426e72302db9c8c78235afc5c335a437a7ad760"
 Fixed #20250 - Added a regression test for negated Q + annotate

 Thanks nott.
 }}}

-- 
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/079.e55d7274a86ebb25bd16c2f5a5833327%40djangoproject.com?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #20250: AttributeError when filtering annotated queryset with negated Q (via fk)

2013-05-19 Thread Django
#20250: AttributeError when filtering annotated queryset with negated Q (via fk)
-+-
 Reporter:  jan.koutny@… |Owner:
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.4
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  annotate |  Needs documentation:  0
  AttributeError |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  1|
Easy pickings:  0|
-+-
Changes (by nott):

 * owner:  nott =>
 * status:  assigned => new


Comment:

 Pull request with a regression test:
 https://github.com/django/django/pull/1165

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




Re: [Django] #20250: AttributeError when filtering annotated queryset with negated Q (via fk)

2013-05-19 Thread Django
#20250: AttributeError when filtering annotated queryset with negated Q (via fk)
-+-
 Reporter:  jan.koutny@… |Owner:  nott
 Type:  Bug  |   Status:  assigned
Component:  Database layer   |  Version:  1.4
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  annotate |  Needs documentation:  0
  AttributeError |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  1|
Easy pickings:  0|
-+-
Changes (by nott):

 * owner:  nobody => nott
 * status:  new => assigned


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




Re: [Django] #20250: AttributeError when filtering annotated queryset with negated Q (via fk)

2013-04-12 Thread Django
#20250: AttributeError when filtering annotated queryset with negated Q (via fk)
-+-
 Reporter:  jan.koutny@… |Owner:  nobody
 Type:  Bug  |   Status:  new
Component:  Database layer   |  Version:  1.4
  (models, ORM)  |   Resolution:
 Severity:  Normal   | Triage Stage:  Accepted
 Keywords:  annotate |  Needs documentation:  0
  AttributeError |  Patch needs improvement:  0
Has patch:  0|UI/UX:  0
  Needs tests:  1|
Easy pickings:  0|
-+-
Changes (by akaariai):

 * status:  closed => new
 * resolution:  fixed =>
 * needs_tests:  0 => 1
 * stage:  Unreviewed => Accepted


Comment:

 Reverting my fixed resolution, regression test should be added even if
 this already works 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.
For more options, visit https://groups.google.com/groups/opt_out.




Re: [Django] #20250: AttributeError when filtering annotated queryset with negated Q (via fk)

2013-04-12 Thread Django
#20250: AttributeError when filtering annotated queryset with negated Q (via fk)
-+-
 Reporter:  jan.koutny@… |Owner:  nobody
 Type:  Bug  |   Status:  closed
Component:  Database layer   |  Version:  1.4
  (models, ORM)  |   Resolution:  fixed
 Severity:  Normal   | Triage Stage:
 Keywords:  annotate |  Unreviewed
  AttributeError |  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
 * needs_docs:   => 0
 * resolution:   => fixed
 * needs_tests:   => 0
 * needs_better_patch:   => 0


Comment:

 This seems to work on master. The results of the print qst.query are:
 {{{
 SELECT "tester_m1"."id", "tester_m1"."rtom3_id", "tester_m1"."x",
 COUNT("tester_m2"."id") AS "m2__count"
 FROM "tester_m1" INNER JOIN "tester_m3" ON ( "tester_m1"."rtom3_id" =
 "tester_m3"."id" )
 LEFT OUTER JOIN "tester_m2" ON ( "tester_m1"."id" = "tester_m2"."rtom1_id"
 )
 WHERE NOT ("tester_m3"."x" = 0 ) GROUP BY "tester_m1"."id",
 "tester_m1"."rtom3_id", "tester_m1"."x"
 }}}
 I haven't verified that the generated query is correct, but at least no
 errors are thrown.

 Backpatching this to 1.4 will not happen as this isn't a critical bug (not
 a dataloss/security/regression/crash bug). I am marking this as fixed.

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




[Django] #20250: AttributeError when filtering annotated queryset with negated Q (via fk)

2013-04-12 Thread Django
#20250: AttributeError when filtering annotated queryset with negated Q (via fk)
--+
 Reporter:  jan.koutny@…  |  Owner:  nobody
 Type:  Bug   | Status:  new
Component:  Database layer (models, ORM)  |Version:  1.4
 Severity:  Normal|   Keywords:  annotate
 Triage Stage:  Unreviewed|  AttributeError
Easy pickings:  0 |  Has patch:  0
  |  UI/UX:  0
--+
 If these conditions are met:
 * annotated queryset
 * Q is filtering attribute related via foreign key
 * Q is negation

 Then {{{AttributeError: 'NoneType' object has no attribute 'startswith'}}}
 exception is throwed. Stack looks the same as in 12687 (fixed), see below.

 Note that *all* conditions above are necessary, code works if one omitted.
 Reproducible with Django 1.4.5, python 2.6.8.

 {{{
 Traceback (most recent call last):
   File "bug.py", line 16, in 
 print qst.query
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py",
 line 167, in __str__
 sql, params = self.sql_with_params()
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py",
 line 175, in sql_with_params
 return self.get_compiler(DEFAULT_DB_ALIAS).as_sql()
   File "/usr/lib/python2.6/site-
 packages/django/db/models/sql/compiler.py", line 82, in as_sql
 where, w_params = self.query.where.as_sql(qn=qn,
 connection=self.connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 91, in as_sql
 sql, params = child.as_sql(qn=qn, connection=connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 91, in as_sql
 sql, params = child.as_sql(qn=qn, connection=connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 91, in as_sql
 sql, params = child.as_sql(qn=qn, connection=connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 91, in as_sql
 sql, params = child.as_sql(qn=qn, connection=connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 91, in as_sql
 sql, params = child.as_sql(qn=qn, connection=connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 94, in as_sql
 sql, params = self.make_atom(child, qn, connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 154, in make_atom
 field_sql = self.sql_for_columns(lvalue, qn, connection)
   File "/usr/lib/python2.6/site-packages/django/db/models/sql/where.py",
 line 227, in sql_for_columns
 lhs = '%s.%s' % (qn(table_alias), qn(name))
   File "/usr/lib/python2.6/site-
 packages/django/db/models/sql/compiler.py", line 49, in
 quote_name_unless_alias
 r = self.connection.ops.quote_name(name)
   File "/usr/lib/python2.6/site-
 packages/django/db/backends/sqlite3/base.py", line 145, in quote_name
 if name.startswith('"') and name.endswith('"'):
 AttributeError: 'NoneType' object has no attribute 'startswith'
 }}}


 Code snippet to reproduce the issue, bug.py:
 {{{
 from bug.models import *
 from django.db.models import Q,Count

 qobj=~Q(rtom3__x=0) #TOXIC
 #qobj=~Q(x=0) #OK
 #qobj=Q(rtom3__x=0) #OK

 qst =  M1.objects.annotate(Count('m2')) #TOXIC
 #qst =  M1.objects.all() #OK

 qst = qst.filter(qobj)

 #Gracefully returns [], no attempt to hit the database
 #print qst

 #Throws an exception!
 print qst.query
 }}}

 and models.py:
 {{{
 from django.db import models

 class M1(models.Model):
 rtom3 = models.ForeignKey("M3")
 x = models.IntegerField()

 class M2(models.Model):
 rtom1 = models.ForeignKey("M1")

 class M3(models.Model):
 x = models.IntegerField()
 }}}

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