mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #17260 -- Added time zone aware aggregation and lookups.
Thanks Carl Meyer for the review. Squashed commit of the following: commit4f290bdb60Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Wed Feb 13 21:21:30 2013 +0100 Used '0:00' instead of 'UTC' which doesn't always exist in Oracle. Thanks Ian Kelly for the suggestion. commit01b6366f3cAuthor: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Wed Feb 13 13:38:43 2013 +0100 Made tzname a parameter of datetime_extract/trunc_sql. This is required to work around a bug in Oracle. commit924a144ef8Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Wed Feb 13 14:47:44 2013 +0100 Added support for parameters in SELECT clauses. commitb4351d2890Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Mon Feb 11 22:30:22 2013 +0100 Documented backwards incompatibilities in the two previous commits. commit91ef84713cAuthor: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Mon Feb 11 09:42:31 2013 +0100 Used QuerySet.datetimes for the admin's date_hierarchy. commit0d0de288a5Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Mon Feb 11 09:29:38 2013 +0100 Used QuerySet.datetimes in date-based generic views. commit9c0859ff7cAuthor: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 21:43:25 2013 +0100 Implemented QuerySet.datetimes on Oracle. commit68ab511a4fAuthor: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 21:43:14 2013 +0100 Implemented QuerySet.datetimes on MySQL. commit22d52681d3Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 21:42:29 2013 +0100 Implemented QuerySet.datetimes on SQLite. commitf6800fd04cAuthor: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 21:43:03 2013 +0100 Implemented QuerySet.datetimes on PostgreSQL. commit0c829c23f4Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 21:41:08 2013 +0100 Added datetime-handling infrastructure in the ORM layers. commit104d82a777Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Mon Feb 11 10:05:55 2013 +0100 Updated null_queries tests to avoid clashing with the __second lookup. commitc01bbb3235Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 23:07:41 2013 +0100 Updated tests of .dates(). Replaced .dates() by .datetimes() for DateTimeFields. Replaced dates with datetimes in the expected output for DateFields. commit50fb7a5246Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 21:40:09 2013 +0100 Updated and added tests for QuerySet.datetimes. commita8451a5004Author: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 22:34:46 2013 +0100 Documented the new time lookups and updated the date lookups. commit29413eab2bAuthor: Aymeric Augustin <aymeric.augustin@m4x.org> Date: Sun Feb 10 16:15:49 2013 +0100 Documented QuerySet.datetimes and updated QuerySet.dates.
This commit is contained in:
@@ -266,34 +266,34 @@ class ModelTest(TestCase):
|
||||
# ... but there will often be more efficient ways if that is all you need:
|
||||
self.assertTrue(Article.objects.filter(id=a8.id).exists())
|
||||
|
||||
# dates() returns a list of available dates of the given scope for
|
||||
# datetimes() returns a list of available dates of the given scope for
|
||||
# the given field.
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.dates('pub_date', 'year'),
|
||||
Article.objects.datetimes('pub_date', 'year'),
|
||||
["datetime.datetime(2005, 1, 1, 0, 0)"])
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.dates('pub_date', 'month'),
|
||||
Article.objects.datetimes('pub_date', 'month'),
|
||||
["datetime.datetime(2005, 7, 1, 0, 0)"])
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.dates('pub_date', 'day'),
|
||||
Article.objects.datetimes('pub_date', 'day'),
|
||||
["datetime.datetime(2005, 7, 28, 0, 0)",
|
||||
"datetime.datetime(2005, 7, 29, 0, 0)",
|
||||
"datetime.datetime(2005, 7, 30, 0, 0)",
|
||||
"datetime.datetime(2005, 7, 31, 0, 0)"])
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.dates('pub_date', 'day', order='ASC'),
|
||||
Article.objects.datetimes('pub_date', 'day', order='ASC'),
|
||||
["datetime.datetime(2005, 7, 28, 0, 0)",
|
||||
"datetime.datetime(2005, 7, 29, 0, 0)",
|
||||
"datetime.datetime(2005, 7, 30, 0, 0)",
|
||||
"datetime.datetime(2005, 7, 31, 0, 0)"])
|
||||
self.assertQuerysetEqual(
|
||||
Article.objects.dates('pub_date', 'day', order='DESC'),
|
||||
Article.objects.datetimes('pub_date', '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)"])
|
||||
|
||||
# dates() requires valid arguments.
|
||||
# datetimes() requires valid arguments.
|
||||
self.assertRaises(
|
||||
TypeError,
|
||||
Article.objects.dates,
|
||||
@@ -324,10 +324,10 @@ class ModelTest(TestCase):
|
||||
order="bad order",
|
||||
)
|
||||
|
||||
# Use iterator() with dates() to return a generator that lazily
|
||||
# Use iterator() with datetimes() to return a generator that lazily
|
||||
# requests each result one at a time, to save memory.
|
||||
dates = []
|
||||
for article in Article.objects.dates('pub_date', 'day', order='DESC').iterator():
|
||||
for article in Article.objects.datetimes('pub_date', 'day', order='DESC').iterator():
|
||||
dates.append(article)
|
||||
self.assertEqual(dates, [
|
||||
datetime(2005, 7, 31, 0, 0),
|
||||
|
||||
Reference in New Issue
Block a user