Opened 12 years ago

Closed 11 years ago

Last modified 11 years ago

#20462 closed Bug (fixed)

Regex lookups should not fail on null/None and non-string values on SQLite

Reported by: noirbizarre Owned by: amclark7
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: sqlite, regex, lookup
Cc: timograham@… Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description

The user function provided to do the regex lookup is buggy for two cases:

  • raise an exception when the value is None (null in databse)
  • raise an exception when the value is not a string

I provided a pull request fixing these issues: https://github.com/django/django/pull/1043

Change History (12)

comment:1 by Anssi Kääriäinen, 11 years ago

Triage Stage: UnreviewedAccepted

Ensuring that all databases behave the same way whenever this is possible is a good idea.

comment:2 by Kamu, 11 years ago

Triage Stage: AcceptedReady for checkin

comment:3 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: newclosed

In 64041f0e6e7a773574d7cde978d16305200004ea:

Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields.

comment:4 by Tim Graham <timograham@…>, 11 years ago

In 92c49d6f01700961698eb3d79fd393d673cee219:

Revert "Fixed #20462 - Fixed sqlite regex lookups for null values and non-string fields."

This reverts commit 64041f0e6e7a773574d7cde978d16305200004ea.

lookup.tests.LookupTests.test_regex_non_string fails under Postgres.
We should also try to rewrite the test using an existing model.

comment:5 by Tim Graham, 11 years ago

Cc: timograham@… added
Patch needs improvement: set
Resolution: fixed
Status: closednew
Triage Stage: Ready for checkinAccepted

comment:6 by amclark7, 11 years ago

Owner: changed from nobody to amclark7
Status: newassigned

comment:7 by amclark7, 11 years ago

Patch needs improvement: unset

Added a pull request for fixing this issue: https://github.com/django/django/pull/1306

This is only a minor change compared to the original patch provided by noirbizarre.

comment:8 by Tim Graham <timograham@…>, 11 years ago

Resolution: fixed
Status: assignedclosed

In 273dc550a4eccdad958541f456332312b3369504:

Fixed #20462 -- null/non-string regex lookups are now consistent

Thanks to noirbizarre for the report and initial patch.

comment:9 by Tim Graham, 11 years ago

Resolution: fixed
Status: closednew

As pointed out in IRC by loic84, the str() cast added in django/db/backends/sqlite3/base.py should probably be something like force_text to properly handle unicode.

comment:11 by Loic Bistuer <loic.bistuer@…>, 11 years ago

Resolution: fixed
Status: newclosed

In a9ea7d8c708c8265cccc17f23c62b2268d9e94f8:

Fixed #20462 - Replaced the str() cast introduced in 273dc55 by force_text()

comment:12 by Tim Graham <timograham@…>, 11 years ago

In b6a87f5c93efa5192433be1e45fc4e79d54efdc7:

Merge pull request #1308 from loic/ticket20462

Fixed #20462 - Replaced the str() cast introduced in 273dc55 by force_text()

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