Django

Code

Ticket #8597 (closed: fixed)

Opened 3 months ago

Last modified 3 months ago

PostgreSQL: r8536 broke iexact lookups with underscores

Reported by: rene.puls@repro-mayr.de Assigned to: nobody
Milestone: 1.0 Component: Database layer (models, ORM)
Version: SVN Keywords:
Cc: Triage Stage: Accepted
Has patch: 0 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Changeset [8536] changed the way field iexact lookups are translated in the PostgreSQL backend. Before the patch, these were translated to "ILIKE %s". Now it's "UPPER(field) = UPPER(%s)". However, the %s value is still escaped for use in a LIKE expression, that is, all underscores are prepended with "\\".

Before the patch (correct):

>>> User.objects.filter(username__iexact='test_user').query.as_sql()
('SELECT [...] FROM "auth_user" WHERE "auth_user"."username"::text ILIKE %s ', (u'test\\_user',))

After the patch (wrong):

User.objects.filter(username__iexact='test_user').query.as_sql()
('SELECT [...] FROM "auth_user" WHERE UPPER("auth_user"."username"::text) = UPPER(%s) ', (u'test\\_user',))

As a result, iexact lookups no longer work in the current version with PostgreSQL, if the comparison value contains an underscore.

Attachments

Change History

08/27/08 08:49:08 changed by jacob

  • needs_better_patch changed.
  • needs_docs changed.
  • stage changed from Unreviewed to Accepted.
  • needs_tests changed.
  • milestone set to 1.0.

08/28/08 00:42:06 changed by mtredinnick

  • status changed from new to closed.
  • resolution set to fixed.

(In [8646]) Fixed #8597 -- Allow the use of strings containing underscores and percentage signs in "iexact" queries on PostgreSQL again (this case was missed in [8536]).


Add/Change #8597 (PostgreSQL: r8536 broke iexact lookups with underscores)




Change Properties
Action