Ticket #3461: 3461-cursor-options.patch

File 3461-cursor-options.patch, 2.7 KB (added by cgrady, 7 years ago)
  • django/db/backends/postgresql/base.py

     
    8282        'iendswith': 'ILIKE %s',
    8383    }
    8484
    85     def _cursor(self, settings):
     85    def _cursor(self, settings, *args, **kwargs):
    8686        set_tz = False
    8787        if self.connection is None:
    8888            set_tz = True
     
    100100                conn_string += " port=%s" % settings.DATABASE_PORT
    101101            self.connection = Database.connect(conn_string, **self.options)
    102102            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    103         cursor = self.connection.cursor()
     103        cursor = self.connection.cursor(*args, **kwargs)
    104104        if set_tz:
    105105            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
    106106        cursor.execute("SET client_encoding to 'UNICODE'")
  • django/db/backends/mysql/base.py

     
    165165                self.connection = None
    166166        return False
    167167
    168     def _cursor(self, settings):
     168    def _cursor(self, settings, *args, **kwargs):
    169169        if not self._valid_connection():
    170170            kwargs = {
    171171                'conv': django_conversions,
     
    186186                kwargs['port'] = int(settings.DATABASE_PORT)
    187187            kwargs.update(self.options)
    188188            self.connection = Database.connect(**kwargs)
    189         cursor = self.connection.cursor()
     189        cursor = self.connection.cursor(*args, **kwargs)
    190190        return cursor
    191191
    192192    def _rollback(self):
  • django/db/backends/postgresql_psycopg2/base.py

     
    5050        'iendswith': 'ILIKE %s',
    5151    }
    5252
    53     def _cursor(self, settings):
     53    def _cursor(self, settings, *args, **kwargs):
    5454        set_tz = False
    5555        if self.connection is None:
    5656            set_tz = True
     
    6969            self.connection = Database.connect(conn_string, **self.options)
    7070            self.connection.set_isolation_level(1) # make transactions transparent to all cursors
    7171            self.connection.set_client_encoding('UTF8')
    72         cursor = self.connection.cursor()
     72        cursor = self.connection.cursor(*args, **kwargs)
    7373        cursor.tzinfo_factory = None
    7474        if set_tz:
    7575            cursor.execute("SET TIME ZONE %s", [settings.TIME_ZONE])
Back to Top