summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2016-02-06 09:21:05 -0500
committerTim Graham <timograham@gmail.com>2016-02-08 07:41:56 -0500
commit6b689a505c7a89d497e2e8af690fdf5a00780a2d (patch)
tree3db8baf1b64c28d5e3264387a14e2493dd0499ec
parent530f0adcf3aab3b3eabdc37a5ea6e8943e8135c4 (diff)
[1.9.x] Fixed #26177 -- Fixed a PostgreSQL crash with TIME_ZONE=None and USE_TZ=False.
Backport of 97eb3356b2a7488c8d0ca0e47ef3e538852d44a2 from master
-rw-r--r--django/db/backends/postgresql/base.py2
-rw-r--r--django/test/signals.py2
-rw-r--r--docs/releases/1.8.10.txt3
-rw-r--r--docs/releases/1.9.3.txt3
-rw-r--r--tests/backends/tests.py5
5 files changed, 12 insertions, 3 deletions
diff --git a/django/db/backends/postgresql/base.py b/django/db/backends/postgresql/base.py
index 383601e477..6a53648f74 100644
--- a/django/db/backends/postgresql/base.py
+++ b/django/db/backends/postgresql/base.py
@@ -196,7 +196,7 @@ class DatabaseWrapper(BaseDatabaseWrapper):
conn_timezone_name = self.connection.get_parameter_status('TimeZone')
- if conn_timezone_name != self.timezone_name:
+ if self.timezone_name and conn_timezone_name != self.timezone_name:
cursor = self.connection.cursor()
try:
cursor.execute(self.ops.set_time_zone_sql(), [self.timezone_name])
diff --git a/django/test/signals.py b/django/test/signals.py
index f7836637e8..bb04af6efb 100644
--- a/django/test/signals.py
+++ b/django/test/signals.py
@@ -69,7 +69,7 @@ def update_connections_time_zone(**kwargs):
except AttributeError:
pass
tz_sql = conn.ops.set_time_zone_sql()
- if tz_sql:
+ if tz_sql and conn.timezone_name:
with conn.cursor() as cursor:
cursor.execute(tz_sql, [conn.timezone_name])
diff --git a/docs/releases/1.8.10.txt b/docs/releases/1.8.10.txt
index d680bad687..c9e77552e6 100644
--- a/docs/releases/1.8.10.txt
+++ b/docs/releases/1.8.10.txt
@@ -9,4 +9,5 @@ Django 1.8.10 fixes several bugs in 1.8.9.
Bugfixes
========
-* ...
+* Fixed a crash on PostgreSQL that prevented using ``TIME_ZONE=None`` and
+ ``USE_TZ=False`` (:ticket:`26177`).
diff --git a/docs/releases/1.9.3.txt b/docs/releases/1.9.3.txt
index 8686f32c5c..ac62926583 100644
--- a/docs/releases/1.9.3.txt
+++ b/docs/releases/1.9.3.txt
@@ -11,3 +11,6 @@ Bugfixes
* Skipped URL checks (new in 1.9) if the ``ROOT_URLCONF`` setting isn't defined
(:ticket:`26155`).
+
+* Fixed a crash on PostgreSQL that prevented using ``TIME_ZONE=None`` and
+ ``USE_TZ=False`` (:ticket:`26177`).
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 460b522079..1bb019bb55 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -826,6 +826,11 @@ class BackendTestCase(TransactionTestCase):
BaseDatabaseWrapper.queries_limit = old_queries_limit
new_connection.close()
+ def test_timezone_none_use_tz_false(self):
+ connection.ensure_connection()
+ with self.settings(TIME_ZONE=None, USE_TZ=False):
+ connection.init_connection_state()
+
# We don't make these tests conditional because that means we would need to
# check and differentiate between: