Skip to content

Commit

Permalink
Fix cursor.arraysize - pymssql doesn't have arraysize
Browse files Browse the repository at this point in the history
  • Loading branch information
phdru committed Feb 16, 2018
1 parent 96a66ec commit f08401c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions docs/News.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ Drivers

* Fix _setAutoCommit for MSSQL.

* Fix cursor.arraysize - pymssql doesn't have arraysize.

Documentation
-------------

Expand Down
12 changes: 10 additions & 2 deletions sqlobject/inheritance/iteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ def __init__(self, dbconn, rawconn, select, keepConnection=False):
super(InheritableIteration, self).__init__(dbconn, rawconn, select,
keepConnection)
self.lazyColumns = select.ops.get('lazyColumns', False)
self.cursor.arraysize = self.defaultArraySize
try:
self.cursor.arraysize = self.defaultArraySize
self.use_arraysize = True
except AttributeError: # pymssql doesn't have arraysize
self.use_arraysize = False
self._results = []
# Find the index of the childName column
childNameIdx = None
Expand All @@ -24,7 +28,11 @@ def __init__(self, dbconn, rawconn, select, keepConnection=False):

def next(self):
if not self._results:
self._results = list(self.cursor.fetchmany())
if self.use_arraysize:
_results = self.cursor.fetchmany()
else:
_results = self.cursor.fetchmany(size=self.defaultArraySize)
self._results = list(_results)
if not self.lazyColumns:
self.fetchChildren()
if not self._results:
Expand Down

0 comments on commit f08401c

Please sign in to comment.