Details
-
Bug
-
Status: Open (View Workflow)
-
Major
-
Resolution: Unresolved
-
1.0.6
-
None
-
None
-
linux w Server version: 10.4.17-MariaDB MariaDB Server
Description
In SQLAlchemy we are attempting to expand support for inserting rows without any parameters; only the table defaults and/or AUTO_INCREMENT are invoked. mariadb seems to fail when the VALUES(DEFAULT) syntax is used with cursor.executemany() only. The script below illustrates the failure, contrasting to the pymysql driver which like all other drivers tested does not have this issue:
import pymysql
|
import mariadb
|
|
|
def run_test(conn):
|
print("RUNNING AGAINST: %s" % conn)
|
cursor = conn.cursor()
|
|
cursor.execute("DROP TABLE IF EXISTS a")
|
|
cursor.execute(
|
"CREATE TABLE IF NOT EXISTS a(id INTEGER PRIMARY KEY AUTO_INCREMENT)"
|
)
|
|
# illustrate the syntax
|
cursor.execute(
|
"INSERT INTO a (id) VALUES (DEFAULT)",
|
(),
|
)
|
|
# now run with executemany
|
try:
|
cursor.executemany(
|
"INSERT INTO a (id) VALUES (DEFAULT)",
|
[(), (), ()],
|
)
|
except Exception as err:
|
print("FAILED! %s" % err)
|
else:
|
print("SUCCEEDED!")
|
|
conn.rollback()
|
|
|
pconn = pymysql.connect(
|
user="scott", password="tiger", host="localhost", db="test"
|
)
|
mconn = mariadb.connect(
|
user="scott", password="tiger", host="localhost", db="test"
|
)
|
|
|
run_test(pconn)
|
|
run_test(mconn)
|
|
output:
RUNNING AGAINST: <pymysql.connections.Connection object at 0x7f2ce057fcd0>
|
SUCCEEDED!
|
RUNNING AGAINST: <mariadb.connection object at 0x7f2ce0493b40>
|
FAILED! Invalid number of parameters in row 1
|
|
|