Opened 14 years ago

Closed 14 years ago

#14110 closed (wontfix)

iexact lookup doesn't work with subquery values

Reported by: Alexander Schepanovski Owned by: Alexander Schepanovski
Component: Database layer (models, ORM) Version: 1.2
Severity: Keywords: sprintdec2010
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

With PostgreSQL and model

class Category(models.Model):
    title = models.CharField(max_length=127)

we have:

>>> Category.objects.filter(title__icontains=Category.objects.filter(pk=1).values('title'))
DatabaseError: syntax error at or near "("
LINE 1: ...PPER("board_category"."title"::text) LIKE UPPER() (SELECT U0...

>>> print connection.queries[-1]['sql']
SELECT "app_category"."id", "app_category"."title" FROM "app_category" WHERE UPPER("app_category"."title"::text)
LIKE UPPER() (SELECT U0."title" FROM "app_category" U0 WHERE U0."id" = 1 )

problem with every lookup for which %s is in the middle of connection.operators[lookup]

Attachments (1)

where.cast.diff (948 bytes ) - added by Alexander Schepanovski 14 years ago.

Download all attachments as: .zip

Change History (3)

by Alexander Schepanovski, 14 years ago

Attachment: where.cast.diff added

comment:1 by Alexander Schepanovski, 14 years ago

P.S. supplied patch doesn't make it right for icontains but it will do for iexact for postgre and many lookups for oracle.

Also, current code assume that connection.operators[lookup] will end with %s which is wrong.

comment:2 by aweakley, 14 years ago

Keywords: sprintdec2010 added
Resolution: wontfix
Status: newclosed

I ran this past Russ.
This seems like very much an edge case, relying on the fact that a one-item values result could be interpreted as a string.

Note: See TracTickets for help on using tickets.
Back to Top