Apache setup using sqlite3 breaks when performing a field__regex filter
|Reported by:||eternicode||Owned by:||nobody|
|Component:||Database layer (models, ORM)||Version:||1.2|
|Severity:||Normal||Keywords:||sqlite3 apache operationalerror databaseerror regex|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
Using a simple apache mod_wsgi setup, setting the project to use sqlite3 as the backend, and running
MyModel.objects.filter(field__regex=r'') (and later evaluating that query with a
.count() ) causes the backend to throw an "
OperationalError: user-defined function raised exception".
I've managed to trace this to the '
import re' statement inside
db/backends/sqlite3/base.py. After moving that import statement to outside that function (making it a module-level import), the exception is no longer raised and everything works fine.
My specific regex that I initially tried was
r'\bfeatured\b' on a django-tagging
TagField, but it happened with an empty string (
r'') as well.
I noticed this while using 1.1.2. A quick test with 1.2 confirmed the error shows up there (as a
DatabaseError, same message), too. I haven't tested with SVN.
Strangely, the regex filter works perfectly when run from
./manage.py shell, or from the same page viewed on
./manage.py runserver. It's just when it's setup with apache that it has issues for some reason.
Change History (10)
comment:8 Changed 5 years ago by