Ticket #3459: settimezone.diff

File settimezone.diff, 1.1 KB (added by Jack Moffitt <metajack@…>, 18 years ago)

patch to call SET TIME ZONE only on new connections instead of for every cursor

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

     
    2828
    2929    def cursor(self):
    3030        from django.conf import settings
     31        set_tz = False
    3132        if self.connection is None:
     33            set_tz = True
    3234            if settings.DATABASE_NAME == '':
    3335                from django.core.exceptions import ImproperlyConfigured
    3436                raise ImproperlyConfigured, "You need to specify DATABASE_NAME in your Django settings file."
     
    4547            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    4648        cursor = self.connection.cursor()
    4749        cursor.tzinfo_factory = None
    48         cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
     50        if set_tz:
     51            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
    4952        if settings.DEBUG:
    5053            return util.CursorDebugWrapper(cursor, self)
    5154        return cursor
Back to Top