Skip to content

Commit

Permalink
Fix for CONPY-212
Browse files Browse the repository at this point in the history
The default settiing for buffered in cursors.execute() method has
to be None:
- if not specified, it will use cursor defaults
- if specified, the default behavior of cursor will be changed
  • Loading branch information
9EOR9 committed Jun 29, 2022
1 parent ba56c73 commit 09e5cad
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
12 changes: 6 additions & 6 deletions mariadb/cursors.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def nextset(self):
self.check_closed()
return super()._nextset()

def execute(self, statement: str, data: Sequence =(), buffered=False):
def execute(self, statement: str, data: Sequence =(), buffered=None):
"""
Prepare and execute a SQL statement.
Expand All @@ -235,9 +235,9 @@ def execute(self, statement: str, data: Sequence =(), buffered=False):
This is most effective for algorithms where the same operation is used,
but different parameters are bound to it (many times).
By default execute() method generates an unbuffered result set for
statements which return data, setting optional parameter buffered to
True will generate buffered result sets.
By default execute() method generates an buffered result unless the optional
parameter buffered was set to False or the cursor was generated as an
unbuffered cursor.
"""

self.check_closed()
Expand All @@ -246,8 +246,8 @@ def execute(self, statement: str, data: Sequence =(), buffered=False):
do_parse= True
self._rowcount= 0

if buffered:
self.buffered= True
if buffered != None:
self.buffered= buffered

# clear pending result sets
if self.field_count:
Expand Down
3 changes: 3 additions & 0 deletions testing/test/integration/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -985,6 +985,9 @@ def test_conpy67(self):
cur = con.cursor(buffered=False)
cur.execute("SELECT 1")
self.assertEqual(cur.rowcount, 0)
cur = con.cursor()
cur.execute("SELECT 1", buffered=False)
self.assertEqual(cur.rowcount, 0)
cur.close()

cur = con.cursor()
Expand Down

0 comments on commit 09e5cad

Please sign in to comment.