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
This commit is contained in:
Adrian Holovaty 2006-01-09 01:48:02 +00:00
parent 1994ebb811
commit 8b1662a185
1 changed files with 13 additions and 4 deletions

View File

@ -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]
"""