Obviously the subquery has too many columns, namely
two:  "error_test"."id", and "error_test"."name",
but you want that only  "error_test"."id" is NOT in select
elements of the subquery.
I'm not even sure that your approch makes sense.

Greetings, Ogi


>Hi all,

>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"
 >     )
>  )

>Same thing happens when:

>print Test.objects.filter(pk__in=pks)

>Should this be ticketed? Should I tweak the app to ensure this doesn't
>happen?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to