tickets: 8597
This data as json
id | created | changetime | last_pulled_from_trac | stage | status | component | type | severity | version | resolution | summary | description | owner | reporter | keywords | easy | has_patch | needs_better_patch | needs_tests | needs_docs | ui_ux |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
8597 | 2008-08-27 09:54:41 | 2011-09-28 16:12:17 | 2022-03-06 03:42:40.624052 | Accepted | closed | Database layer (models, ORM) | dev | fixed | PostgreSQL: r8536 broke iexact lookups with underscores | 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. | nobody | rene.puls@repro-mayr.de | 0 | 0 | 0 | 0 | 0 | 0 |