Opened 14 years ago

Closed 14 years ago

#15914 closed Bug (duplicate)

F-expressions used with iexact lookup produces invalid SQL

Reported by: Łukasz Rekucki Owned by: nobody
Component: Database layer (models, ORM) Version: 1.2
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Example queries generated from Employee.objects.filter(firstname__iexact=F('lastname')):

-- 1. PostgreSQL

SELECT "expressions_employee"."id", "expressions_employee"."firstname", "expressions_employee"."lastname" 
FROM "expressions_employee" WHERE UPPER("expressions_employee"."firstname"::text) = UPPER() "expressions_employee"."lastname"
-- DatabaseError: syntax error at or near ""expressions_employee""
-- LINE 1: ...xpressions_employee"."firstname"::text) = UPPER() "expressio...

-- 2. SQLite

SELECT "expressions_employee"."id", "expressions_employee"."firstname", "expressions_employee"."lastname" 
FROM "expressions_employee" WHERE "expressions_employee"."firstname" LIKE  ESCAPE '\' "expressions_employee"."lastname"
-- DatabaseError: near "ESCAPE": syntax error

I found the error on Django 1.2. Reproduced on trunk (see attachment)

Attachments (1)

iexact_regression.diff (700 bytes ) - added by Łukasz Rekucki 14 years ago.
Test case to reproduce the error.

Download all attachments as: .zip

Change History (2)

by Łukasz Rekucki, 14 years ago

Attachment: iexact_regression.diff added

Test case to reproduce the error.

comment:1 by Aymeric Augustin, 14 years ago

Resolution: duplicate
Status: newclosed

I could reproduce the error with that test case.

It seems to me that #11722 reported the same problem.

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