Re: [Django] #14011: QuerySet.none().values('x').query causes "DatabaseError: subquery has too many columns" when used in filters.

2010-10-05 Thread Django
#14011: QuerySet.none().values('x').query causes "DatabaseError: subquery has 
too
many columns" when used in filters.
--+-
  Reporter:  skatei   | Owner:  

Status:  new  | Milestone:  

 Component:  ORM aggregation  |   Version:  1.2 

Resolution:   |  Keywords:  none 
query DatabaseError
 Stage:  Accepted | Has_patch:  0   

Needs_docs:  0|   Needs_tests:  0   

Needs_better_patch:  0|  
--+-
Changes (by mk):

  * stage:  Unreviewed => Accepted

Comment:

 Here's a test for this issue. The failure is still present in trunk.

-- 
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] #14011: QuerySet.none().values('x').query causes "DatabaseError: subquery has too many columns" when used in filters.

2010-08-22 Thread Django
#14011: QuerySet.none().values('x').query causes "DatabaseError: subquery has 
too
many columns" when used in filters.
--+-
  Reporter:  skatei   | Owner:  

Status:  new  | Milestone:  

 Component:  ORM aggregation  |   Version:  1.2 

Resolution:   |  Keywords:  none 
query DatabaseError
 Stage:  Unreviewed   | Has_patch:  0   

Needs_docs:  0|   Needs_tests:  0   

Needs_better_patch:  0|  
--+-
Changes (by lrekucki):

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

Comment:

 This particular error is caused by how EmptyQuerySet handles values().

 {{{
 >>> print DummyModel.objects.values('pk').none().query
 SELECT "simple_dummymodel"."id" FROM "simple_dummymodel"
 >>> print DummyModel.objects.none().values('pk').query
 SELECT "simple_dummymodel"."id", "simple_dummymodel"."string",
 "simple_dummymodel"."text" FROM "simple_dummymodel"
 }}}
 The returned QuerySet yields wrong SQL which includes additional columns.
 This is not a problem, because EmptyQuerySets aren't executed, they just
 return empty list as their value. The following code should work properly
 (I'm not entirely sure why this won't execute a query, but it works):
 {{{
 pks = Test.objects.none().values('pk')
 print Test.objects.exclude(pk__in=pks)
 }}}

 I guess the first issue could be fixed, but it wouldn't change the fact
 that {{{.query}}} of the EmptyQuerySet doesn't reflect it's result:
 {{{
 >>> print
 DummyModel.objects.filter(pk__in=DummyModel.objects.values('pk').none().query)
 [] # should always be []
 }}}

-- 
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] #14011: QuerySet.none().values('x').query causes "DatabaseError: subquery has too many columns" when used in filters.

2010-07-26 Thread Django
#14011: QuerySet.none().values('x').query causes "DatabaseError: subquery has 
too
many columns" when used in filters.
-+--
 Reporter:  skatei   |  Status:  new
 
Milestone:   |   Component:  ORM aggregation
 
  Version:  1.2  |Keywords:  none query 
DatabaseError
Stage:  Unreviewed   |   Has_patch:  0  
 
-+--
 Just came across this error.

 {{{
 class Test(models.Model):
   name = models.CharField(max_length=20)

 test = Test(name='bob')
 test.save()
 pks = Test.objects.none().values('pk').query
 print Test.objects.exclude(pk__in=pks)

 DatabaseError: subquery has too many columns
 }}}

 The query:

 {{{
 SELECT
   "error_test"."id",
   "error_test"."name",
 FROM
   "error_test"
 WHERE
   NOT (
 "error_test"."id"
   IN (
 SELECT
   "error_test"."id",
   "error_test"."name",
 FROM
   "error_test"
   )
   )
 }}}

 Fixes?:

 * Substitute with {{{.filter(pk__in=[])}}} (possibly overriding none).

 * Catch and deal with the exception.

 * Don't let this happen in the code.

 This should at least raise a more meaningful exception if deemed
 incorrect.

 Reason i'd like it to work is because I apply filters dynamically, using
 some complex logic that sometimes applies a none filter.

-- 
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.