Ticket #14555: pgtz.patch

File pgtz.patch, 1.2 KB (added by John Hensley, 13 years ago)

Patch to set time zone before each query

  • django/db/backends/postgresql_psycopg2/base.py

    diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
    index f0a89e5..75ebc3f 100644
    a b class CursorWrapper(object):  
    3838    particular exception instances and reraise them with the right types.
    3939    """
    4040
    41     def __init__(self, cursor):
     41    def __init__(self, cursor, settings_dict):
    4242        self.cursor = cursor
     43        self.settings_dict = settings_dict
    4344
    4445    def execute(self, query, args=None):
    4546        try:
     47            self.cursor.execute("SET TIME ZONE %s", [self.settings_dict['TIME_ZONE']])
    4648            return self.cursor.execute(query, args)
    4749        except Database.IntegrityError, e:
    4850            raise utils.IntegrityError, utils.IntegrityError(*tuple(e)), sys.exc_info()[2]
    class DatabaseWrapper(BaseDatabaseWrapper):  
    176178            if set_tz:
    177179                cursor.execute("SET TIME ZONE %s", [settings_dict['TIME_ZONE']])
    178180            self._get_pg_version()
    179         return CursorWrapper(cursor)
     181        return CursorWrapper(cursor, settings_dict)
    180182
    181183    def _enter_transaction_management(self, managed):
    182184        """
Back to Top