From 2f45af6f58eaf30962b0cbc75b6bb79aaf8f347e Mon Sep 17 00:00:00 2001 From: Joseph Kocherhans Date: Wed, 24 Feb 2010 15:29:25 +0000 Subject: 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 --- django/db/backends/sqlite3/base.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'django') 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 "" -- cgit v1.3