Opened 3 years ago

Closed 3 years ago

#15914 closed Bug (duplicate)

F-expressions used with iexact lookup produces invalid SQL

Reported by: lrekucki 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:


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 lrekucki 3 years ago.
Test case to reproduce the error.

Download all attachments as: .zip

Change History (2)

Changed 3 years ago by lrekucki

Test case to reproduce the error.

comment:1 Changed 3 years ago by aaugustin

  • Resolution set to duplicate
  • Status changed from new to closed

I could reproduce the error with that test case.

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

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.