From 8b1662a185d2c8b61b312e96c6269097c4b5ecbc Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Mon, 9 Jan 2006 01:48:02 +0000 Subject: [PATCH] magic-removal: Changed 'reserved_names' model unit tests to add tests that get_date_extract_sql and get_date_trunc_sql properly escape table and column names git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1877 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- tests/modeltests/reserved_names/models.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/tests/modeltests/reserved_names/models.py b/tests/modeltests/reserved_names/models.py index e2cb4a7e31..75e7627a13 100644 --- a/tests/modeltests/reserved_names/models.py +++ b/tests/modeltests/reserved_names/models.py @@ -16,7 +16,7 @@ class Thing(models.Model): drop = models.CharField(maxlength=1) alter = models.CharField(maxlength=1) having = models.CharField(maxlength=1) - where = models.CharField(maxlength=1) + where = models.DateField(maxlength=1) has_hyphen = models.CharField(maxlength=1, db_column='has-hyphen') class Meta: db_table = 'select' @@ -25,12 +25,15 @@ class Thing(models.Model): return self.when API_TESTS = """ ->>> t = Thing(when='a', join='b', like='c', drop='d', alter='e', having='f', where='g', has_hyphen='h') +>>> import datetime +>>> day1 = datetime.date(2005, 1, 1) +>>> day2 = datetime.date(2006, 2, 2) +>>> t = Thing(when='a', join='b', like='c', drop='d', alter='e', having='f', where=day1, has_hyphen='h') >>> t.save() >>> print t.when a ->>> u = Thing(when='h', join='i', like='j', drop='k', alter='l', having='m', where='n') +>>> u = Thing(when='h', join='i', like='j', drop='k', alter='l', having='m', where=day2) >>> u.save() >>> print u.when h @@ -41,7 +44,13 @@ h >>> print v.join b >>> print v.where -g +2005-01-01 >>> Thing.objects.get_list(order_by=['select.when']) [a, h] + +>>> Thing.objects.get_where_list('year') +[datetime.datetime(2005, 1, 1, 0, 0), datetime.datetime(2006, 1, 1, 0, 0)] + +>>> Thing.objects.get_list(where__month=1) +[a] """