diff options
| author | Matthew Somerville <matthew-github@dracos.co.uk> | 2015-05-22 20:16:26 +0100 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2015-06-04 22:27:13 -0400 |
| commit | 2dc93bb10ab1c2af1df9977f1b51d47cadab7b21 (patch) | |
| tree | 2a475411606bca58abbe9d73d83ccac5506bbe9f /docs | |
| parent | 6700c909358d2ff9ff96f28dbc549906d8d32206 (diff) | |
Fixed #22316 -- Added time filters to TimeField on SQLite.
This was implemented for non-SQLite backends in 1.7 (as a
side effect of #16187).
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/ref/models/querysets.txt | 45 | ||||
| -rw-r--r-- | docs/releases/1.9.txt | 10 |
2 files changed, 43 insertions, 12 deletions
diff --git a/docs/ref/models/querysets.txt b/docs/ref/models/querysets.txt index 0a0749d0c9..a333ce7b56 100644 --- a/docs/ref/models/querysets.txt +++ b/docs/ref/models/querysets.txt @@ -2606,23 +2606,30 @@ in the database <database-time-zone-definitions>`. hour ~~~~ -For datetime fields, an exact hour match. Allows chaining additional field -lookups. Takes an integer between 0 and 23. +For datetime and time fields, an exact hour match. Allows chaining additional +field lookups. Takes an integer between 0 and 23. Example:: Event.objects.filter(timestamp__hour=23) + Event.objects.filter(time__hour=5) Event.objects.filter(timestamp__hour__gte=12) SQL equivalent:: SELECT ... WHERE EXTRACT('hour' FROM timestamp) = '23'; + SELECT ... WHERE EXTRACT('hour' FROM time) = '5'; SELECT ... WHERE EXTRACT('hour' FROM timestamp) >= '12'; (The exact SQL syntax varies for each database engine.) -When :setting:`USE_TZ` is ``True``, values are converted to the current time -zone before filtering. +For datetime fields, when :setting:`USE_TZ` is ``True``, values are converted +to the current time zone before filtering. + +.. versionchanged:: 1.9 + + Added support for :class:`~django.db.models.TimeField` on SQLite (other + databases supported it as of 1.7). .. versionchanged:: 1.9 @@ -2633,23 +2640,30 @@ zone before filtering. minute ~~~~~~ -For datetime fields, an exact minute match. Allows chaining additional field -lookups. Takes an integer between 0 and 59. +For datetime and time fields, an exact minute match. Allows chaining additional +field lookups. Takes an integer between 0 and 59. Example:: Event.objects.filter(timestamp__minute=29) + Event.objects.filter(time__minute=46) Event.objects.filter(timestamp__minute__gte=29) SQL equivalent:: SELECT ... WHERE EXTRACT('minute' FROM timestamp) = '29'; + SELECT ... WHERE EXTRACT('minute' FROM time) = '46'; SELECT ... WHERE EXTRACT('minute' FROM timestamp) >= '29'; (The exact SQL syntax varies for each database engine.) -When :setting:`USE_TZ` is ``True``, values are converted to the current time -zone before filtering. +For datetime fields, When :setting:`USE_TZ` is ``True``, values are converted +to the current time zone before filtering. + +.. versionchanged:: 1.9 + + Added support for :class:`~django.db.models.TimeField` on SQLite (other + databases supported it as of 1.7). .. versionchanged:: 1.9 @@ -2660,23 +2674,30 @@ zone before filtering. second ~~~~~~ -For datetime fields, an exact second match. Allows chaining additional field -lookups. Takes an integer between 0 and 59. +For datetime and time fields, an exact second match. Allows chaining additional +field lookups. Takes an integer between 0 and 59. Example:: Event.objects.filter(timestamp__second=31) + Event.objects.filter(time__second=2) Event.objects.filter(timestamp__second__gte=31) SQL equivalent:: SELECT ... WHERE EXTRACT('second' FROM timestamp) = '31'; + SELECT ... WHERE EXTRACT('second' FROM time) = '2'; SELECT ... WHERE EXTRACT('second' FROM timestamp) >= '31'; (The exact SQL syntax varies for each database engine.) -When :setting:`USE_TZ` is ``True``, values are converted to the current time -zone before filtering. +For datetime fields, when :setting:`USE_TZ` is ``True``, values are converted +to the current time zone before filtering. + +.. versionchanged:: 1.9 + + Added support for :class:`~django.db.models.TimeField` on SQLite (other + databases supported it as of 1.7). .. versionchanged:: 1.9 diff --git a/docs/releases/1.9.txt b/docs/releases/1.9.txt index e06946aaa6..f43fe07f08 100644 --- a/docs/releases/1.9.txt +++ b/docs/releases/1.9.txt @@ -245,6 +245,10 @@ Models (such as :lookup:`exact`, :lookup:`gt`, :lookup:`lt`, etc.). For example: ``Entry.objects.filter(pub_date__month__gt=6)``. +* Time lookups (hour, minute, second) are now supported by + :class:`~django.db.models.TimeField` for all database backends. Support for + backends other than SQLite was added but undocumented in Django 1.7. + * You can specify the ``output_field`` parameter of the :class:`~django.db.models.Avg` aggregate in order to aggregate over non-numeric columns, such as ``DurationField``. @@ -374,6 +378,12 @@ Database backend API * To use the new ``date`` lookup, third-party database backends may need to implement the ``DatabaseOperations.datetime_cast_date_sql()`` method. +* The ``DatabaseOperations.time_extract_sql()`` method was added. It calls the + existing ``date_extract_sql()`` method. This method is overridden by the + SQLite backend to add time lookups (hour, minute, second) to + :class:`~django.db.models.TimeField`, and may be needed by third-party + database backends. + Default settings that were tuples are now lists ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
