mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
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
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Unit and doctests for specific database backends.
|
||||
import datetime
|
||||
import models
|
||||
import unittest
|
||||
from django.db import backend, connection, DEFAULT_DB_ALIAS
|
||||
from django.db.backends.signals import connection_created
|
||||
from django.conf import settings
|
||||
from django.test import TestCase
|
||||
|
||||
class Callproc(unittest.TestCase):
|
||||
|
||||
@@ -34,6 +37,35 @@ class LongString(unittest.TestCase):
|
||||
c.execute('DROP TABLE ltext')
|
||||
self.assertEquals(long_str, row[0].read())
|
||||
|
||||
class DateQuotingTest(TestCase):
|
||||
|
||||
def test_django_date_trunc(self):
|
||||
"""
|
||||
Test the custom ``django_date_trunc method``, in particular against
|
||||
fields which clash with strings passed to it (e.g. 'year') - see
|
||||
#12818__.
|
||||
|
||||
__: http://code.djangoproject.com/ticket/12818
|
||||
|
||||
"""
|
||||
updated = datetime.datetime(2010, 2, 20)
|
||||
models.SchoolClass.objects.create(year=2009, last_updated=updated)
|
||||
years = models.SchoolClass.objects.dates('last_updated', 'year')
|
||||
self.assertEqual(list(years), [datetime.datetime(2010, 1, 1, 0, 0)])
|
||||
|
||||
def test_django_extract(self):
|
||||
"""
|
||||
Test the custom ``django_extract method``, in particular against fields
|
||||
which clash with strings passed to it (e.g. 'day') - see #12818__.
|
||||
|
||||
__: http://code.djangoproject.com/ticket/12818
|
||||
|
||||
"""
|
||||
updated = datetime.datetime(2010, 2, 20)
|
||||
models.SchoolClass.objects.create(year=2009, last_updated=updated)
|
||||
classes = models.SchoolClass.objects.filter(last_updated__day=20)
|
||||
self.assertEqual(len(classes), 1)
|
||||
|
||||
def connection_created_test(sender, **kwargs):
|
||||
print 'connection_created signal'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user