summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
authorJoseph Kocherhans <joseph@jkocherhans.com>2010-02-24 15:29:25 +0000
committerJoseph Kocherhans <joseph@jkocherhans.com>2010-02-24 15:29:25 +0000
commit2f45af6f58eaf30962b0cbc75b6bb79aaf8f347e (patch)
tree68791b59054abd8444779bdacfad6ad009b6304f /django
parentd76fc2c2a028ed8672c5a89ebc0f9182ef080dde (diff)
Fixed #12818. SQLite now properly quotes strings for date extraction and truncation. Thanks, SmilyChris.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@12573 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
-rw-r--r--django/db/backends/sqlite3/base.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index a9b1aa3f8b..8ddb736d89 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -63,13 +63,17 @@ class DatabaseFeatures(BaseDatabaseFeatures):
class DatabaseOperations(BaseDatabaseOperations):
def date_extract_sql(self, lookup_type, field_name):
# sqlite doesn't support extract, so we fake it with the user-defined
- # function django_extract that's registered in connect().
- return 'django_extract("%s", %s)' % (lookup_type.lower(), field_name)
+ # function django_extract that's registered in connect(). Note that
+ # single quotes are used because this is a string (and could otherwise
+ # cause a collision with a field name).
+ return "django_extract('%s', %s)" % (lookup_type.lower(), field_name)
def date_trunc_sql(self, lookup_type, field_name):
# sqlite doesn't support DATE_TRUNC, so we fake it with a user-defined
- # function django_date_trunc that's registered in connect().
- return 'django_date_trunc("%s", %s)' % (lookup_type.lower(), field_name)
+ # function django_date_trunc that's registered in connect(). Note that
+ # single quotes are used because this is a string (and could otherwise
+ # cause a collision with a field name).
+ return "django_date_trunc('%s', %s)" % (lookup_type.lower(), field_name)
def drop_foreignkey_sql(self):
return ""