mirror of
https://github.com/mariadb-corporation/mariadb-connector-python.git
synced 2025-08-06 18:19:50 +00:00
Fix for CONPY-48:
According to PEP-249 parameters for cursor methods execute() and executemany() are passed as a sequence. The current implementation accepted Tuple only, this fix also allows List as parameter. Valid examples: cursor.execute("SELECT %s", [1]) cursor.execute("SELECT %s", (1,)) cursor.executemany("INSERT INTO t1 VALUES (%s)", [[1],[2]]) cursor.executemany("INSERT INTO t1 VALUES (%s)", [(1,),(2,)]) cursor.executemany("INSERT INTO t1 VALUES (%s)", [[1],(2,)])
This commit is contained in:
@ -786,6 +786,22 @@ class TestCursor(unittest.TestCase):
|
||||
self.assertEqual(row[0], 0)
|
||||
del con
|
||||
|
||||
def test_conpy49(self):
|
||||
con= create_connection()
|
||||
cur=con.cursor()
|
||||
cur.execute("select %s", [True])
|
||||
row= cur.fetchone()
|
||||
self.assertEqual(row[0], 1)
|
||||
cur.execute("create temporary table t1 (a int)")
|
||||
cur.executemany("insert into t1 values (%s)", [[1],(2,)])
|
||||
cur.execute("select a from t1")
|
||||
row= cur.fetchone()
|
||||
self.assertEqual(row[0], 1)
|
||||
row= cur.fetchone()
|
||||
self.assertEqual(row[0], 2)
|
||||
del con
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user