Merge branch 'fix-1019'

This commit is contained in:
Daniele Varrazzo 2019-12-10 11:09:27 +00:00
commit c3b35ba510
2 changed files with 13 additions and 5 deletions

7
NEWS
View File

@ -1,6 +1,13 @@
Current release Current release
--------------- ---------------
What's new in psycopg 2.8.5
^^^^^^^^^^^^^^^^^^^^^^^^^^^
- Fixed use of `!connection_factory` and `!cursor_factory` together
(:ticket:`#1019`).
What's new in psycopg 2.8.4 What's new in psycopg 2.8.4
^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -124,7 +124,7 @@ class DictCursorBase(_cursor):
class DictConnection(_connection): class DictConnection(_connection):
"""A connection that uses `DictCursor` automatically.""" """A connection that uses `DictCursor` automatically."""
def cursor(self, *args, **kwargs): def cursor(self, *args, **kwargs):
kwargs.setdefault('cursor_factory', DictCursor) kwargs.setdefault('cursor_factory', self.cursor_factory or DictCursor)
return super(DictConnection, self).cursor(*args, **kwargs) return super(DictConnection, self).cursor(*args, **kwargs)
@ -221,7 +221,7 @@ class DictRow(list):
class RealDictConnection(_connection): class RealDictConnection(_connection):
"""A connection that uses `RealDictCursor` automatically.""" """A connection that uses `RealDictCursor` automatically."""
def cursor(self, *args, **kwargs): def cursor(self, *args, **kwargs):
kwargs.setdefault('cursor_factory', RealDictCursor) kwargs.setdefault('cursor_factory', self.cursor_factory or RealDictCursor)
return super(RealDictConnection, self).cursor(*args, **kwargs) return super(RealDictConnection, self).cursor(*args, **kwargs)
@ -291,7 +291,7 @@ class RealDictRow(OrderedDict):
class NamedTupleConnection(_connection): class NamedTupleConnection(_connection):
"""A connection that uses `NamedTupleCursor` automatically.""" """A connection that uses `NamedTupleCursor` automatically."""
def cursor(self, *args, **kwargs): def cursor(self, *args, **kwargs):
kwargs.setdefault('cursor_factory', NamedTupleCursor) kwargs.setdefault('cursor_factory', self.cursor_factory or NamedTupleCursor)
return super(NamedTupleConnection, self).cursor(*args, **kwargs) return super(NamedTupleConnection, self).cursor(*args, **kwargs)
@ -442,7 +442,7 @@ class LoggingConnection(_connection):
def cursor(self, *args, **kwargs): def cursor(self, *args, **kwargs):
self._check() self._check()
kwargs.setdefault('cursor_factory', LoggingCursor) kwargs.setdefault('cursor_factory', self.cursor_factory or LoggingCursor)
return super(LoggingConnection, self).cursor(*args, **kwargs) return super(LoggingConnection, self).cursor(*args, **kwargs)
@ -485,7 +485,8 @@ class MinTimeLoggingConnection(LoggingConnection):
return msg + _os.linesep + " (execution time: %d ms)" % t return msg + _os.linesep + " (execution time: %d ms)" % t
def cursor(self, *args, **kwargs): def cursor(self, *args, **kwargs):
kwargs.setdefault('cursor_factory', MinTimeLoggingCursor) kwargs.setdefault('cursor_factory',
self.cursor_factory or MinTimeLoggingCursor)
return LoggingConnection.cursor(self, *args, **kwargs) return LoggingConnection.cursor(self, *args, **kwargs)