1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

magic-removal: Cleaned up get_in_bulk() and __get_date_list() DB queries to match documentation and improve error checking.

git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1885 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Russell Keith-Magee
2006-01-09 14:34:17 +00:00
parent dde6963869
commit 0389e6261b
3 changed files with 28 additions and 17 deletions

View File

@@ -180,6 +180,17 @@ False
>>> Article.objects.get_pub_date_list('day', order='DESC')
[datetime.datetime(2005, 7, 31, 0, 0), datetime.datetime(2005, 7, 30, 0, 0), datetime.datetime(2005, 7, 29, 0, 0), datetime.datetime(2005, 7, 28, 0, 0)]
# Try some bad arguments to __get_date_list
>>> Article.objects.get_pub_date_list('badarg')
Traceback (most recent call last):
...
AssertionError: 'kind' must be one of 'year', 'month' or 'day'.
>>> Article.objects.get_pub_date_list(order='ASC')
Traceback (most recent call last):
...
TypeError: __get_date_list() takes at least 3 non-keyword arguments (2 given)
# An Article instance doesn't have access to the "objects" attribute.
# That is only available as a class method.
>>> a7.objects.get_list()

View File

@@ -69,6 +69,18 @@ Article 4
Traceback (most recent call last):
...
AssertionError: get_in_bulk() cannot be passed an empty ID list.
>>> Article.objects.get_in_bulk('foo')
Traceback (most recent call last):
...
AssertionError: get_in_bulk() must be provided with a list of IDs.
>>> Article.objects.get_in_bulk()
Traceback (most recent call last):
...
TypeError: get_in_bulk() takes at least 2 arguments (1 given)
>>> Article.objects.get_in_bulk(headline__startswith='Blah')
Traceback (most recent call last):
...
TypeError: get_in_bulk() takes at least 2 non-keyword arguments (1 given)
# get_values() is just like get_list(), except it returns a list of
# dictionaries instead of object instances -- and you can specify which fields