diff options
| author | Aymeric Augustin <aymeric.augustin@m4x.org> | 2019-07-20 18:31:47 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2019-12-04 18:07:51 +0100 |
| commit | ad88524e4db91dc2f148cf40184a81a454ee7aac (patch) | |
| tree | ec93dc6c92104fa72276cf75d9a6e952716f77cf | |
| parent | a2e96f7969059fb4e621a1cd591fbdd0d4deae2e (diff) | |
Refs #23524 -- Unified BaseDatabaseWrapper.timezone.
There was a special case in this property to return None when the
database backend supports time zone. However, only the PostgreSQL
backend supports time zones and it never uses this property.
| -rw-r--r-- | django/db/backends/base/base.py | 17 | ||||
| -rw-r--r-- | docs/releases/3.1.txt | 5 |
2 files changed, 15 insertions, 7 deletions
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py index 9a4c27f0f3..08d5f755aa 100644 --- a/django/db/backends/base/base.py +++ b/django/db/backends/base/base.py @@ -117,18 +117,21 @@ class BaseDatabaseWrapper: @cached_property def timezone(self): """ - Time zone for datetimes stored as naive values in the database. + Return a tzinfo of the database connection time zone. - Return a tzinfo object or None. + This is only used when time zone support is enabled. When a datetime is + read from the database, it is always returned in this time zone. - This is only needed when time zone support is enabled and the database - doesn't support time zones. (When the database supports time zones, - the adapter handles aware datetimes so Django doesn't need to.) + When the database backend supports time zones, it doesn't matter which + time zone Django uses, as long as aware datetimes are used everywhere. + For simplicity, Django selects UTC. + + When the database backend doesn't support time zones, the time zone + Django uses can be selected with the TIME_ZONE configuration option, so + it can match what other users of the database expect. """ if not settings.USE_TZ: return None - elif self.features.supports_timezones: - return None elif self.settings_dict['TIME_ZONE'] is None: return timezone.utc else: diff --git a/docs/releases/3.1.txt b/docs/releases/3.1.txt index b4179883ab..58f14e172d 100644 --- a/docs/releases/3.1.txt +++ b/docs/releases/3.1.txt @@ -297,6 +297,11 @@ backends. * ``DatabaseOperations.fetch_returned_insert_columns()`` now requires an additional ``returning_params`` argument. +* ``connection.timezone`` property is now ``'UTC'`` by default, or the + :setting:`TIME_ZONE <DATABASE-TIME_ZONE>` when :setting:`USE_TZ` is ``True`` + on databases that support time zones. Previously, it was ``None`` on + databases that support time zones. + Dropped support for MariaDB 10.1 -------------------------------- |
