summaryrefslogtreecommitdiff
path: root/django/db/backends
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2012-03-13 23:29:15 +0000
committerAymeric Augustin <aymeric.augustin@m4x.org>2012-03-13 23:29:15 +0000
commit3ef55dfaa03b3f5be3ee3632dfc59b8f752d2dec (patch)
tree8124c0dd366ed0c007f3dc0631a761709aa535a6 /django/db/backends
parent4b14546215ad4ef15f04e748e3b5f0da7b613b45 (diff)
Fixed #17882 (again) -- Updated the database connections' time zone when time-zone-related settings are changed in tests.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17709 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/db/backends')
-rw-r--r--django/db/backends/__init__.py8
-rw-r--r--django/db/backends/postgresql_psycopg2/base.py3
-rw-r--r--django/db/backends/postgresql_psycopg2/operations.py3
3 files changed, 13 insertions, 1 deletions
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index 7674f5c879..6f1f4b9618 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -710,6 +710,14 @@ class BaseDatabaseOperations(object):
"""
raise NotImplementedError
+ def set_time_zone_sql(self):
+ """
+ Returns the SQL that will set the connection's time zone.
+
+ Returns '' if the backend doesn't support time zones.
+ """
+ return ''
+
def sql_flush(self, style, tables, sequences):
"""
Returns a list of SQL statements required to remove all data from
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index 802ebf2b80..0d25129313 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -190,7 +190,8 @@ class DatabaseWrapper(BaseDatabaseWrapper):
# Set the time zone in autocommit mode (see #17062)
self.connection.set_isolation_level(
psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
- self.connection.cursor().execute("SET TIME ZONE %s", [tz])
+ self.connection.cursor().execute(
+ self.ops.set_time_zone_sql(), [tz])
self.connection.set_isolation_level(self.isolation_level)
self._get_pg_version()
connection_created.send(sender=self.__class__, connection=self)
diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py
index 949a05c0b6..395cd92047 100644
--- a/django/db/backends/postgresql_psycopg2/operations.py
+++ b/django/db/backends/postgresql_psycopg2/operations.py
@@ -71,6 +71,9 @@ class DatabaseOperations(BaseDatabaseOperations):
return name # Quoting once is enough.
return '"%s"' % name
+ def set_time_zone_sql(self):
+ return "SET TIME ZONE %s"
+
def sql_flush(self, style, tables, sequences):
if tables:
# Perform a single SQL 'TRUNCATE x, y, z...;' statement. It allows