Fix for CONPY-213

Additionally to the fix for CONPY-214 (which fixed the iterator), we
need to check that converter will not be called with EOF (None).
This commit is contained in:
Georg Richter
2022-07-07 13:42:34 +02:00
parent 687ba165cc
commit c30b597ba9
2 changed files with 13 additions and 2 deletions

View File

@ -353,7 +353,7 @@ class Cursor(mariadb._mariadb.cursor):
if not self.field_count: if not self.field_count:
raise mariadb.ProgrammingError("Cursor doesn't have a result set") raise mariadb.ProgrammingError("Cursor doesn't have a result set")
row= super().fetchone() row= super().fetchone()
if self._connection._converter: if self._connection._converter and row:
l= list(row) l= list(row)
if not self._description: if not self._description:
self._description= super().description self._description= super().description

View File

@ -1333,7 +1333,18 @@ class TestCursor(unittest.TestCase):
self.assertEqual(transformed, cursor._transformed_statement) self.assertEqual(transformed, cursor._transformed_statement)
del cursor del cursor
def test_conpy213(self):
conversions= { **{FIELD_TYPE.NEWDECIMAL : float}}
connection = create_connection({"converter": conversions})
cursor= connection.cursor()
cursor.execute("SELECT 1.1")
rows= cursor.fetchall()
self.assertEqual(rows[0][0], 1.1)
cursor.execute("SELECT 1.1")
row= cursor.fetchone()
self.assertEqual(row[0], 1.1)
del cursor
del connection
def test_conpy91(self): def test_conpy91(self):
with create_connection() as connection: with create_connection() as connection: