Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Not a Bug
-
1.0.5
-
None
-
WIndows 10 64bits
Server version: 10.5.8-MariaDB - mariadb.org binary distribution
Description
Sample modified from Official doc:
Using indicators
from mariadb.constants import * |
from my_packages.DatabasePoint import database_on_demand |
|
def database_on_demand():
|
return mariadb.connect( |
user="root", database="test", host="127.0.0.1", password="test", connect_timeout=180, read_timeout=180, write_timeout=180, autocommit=True) |
|
|
conn = database_on_demand()
|
cursor = conn.cursor()
|
cursor.execute("CREATE OR REPLACE TABLE cakes(id int, cake varchar(100), price decimal(10,2) default 1.99)") |
|
sql= "INSERT INTO cakes (id, cake, price) VALUES (?,?,?)" |
data= [(1, "Cherry Cake", 2.10), (2, "Apple Cake", INDICATOR.DEFAULT)] |
cursor.execute(sql, data[1]) # does not work |
cursor.executemany(sql, data) # works
|
cursor.execute(sql, data[1]) # after executemany it works |
Expected output:
2 Apple Cake 1.99
2 Apple Cake 1.99
1 Cherry Cake 2.10
2 Apple Cake 1.99
2 Apple Cake 1.99
2 Apple Cake 1.99
Current output:
2 Apple Cake
2 Apple Cake
1 Cherry Cake 2.10
2 Apple Cake 1.99
2 Apple Cake 1.99
2 Apple Cake 1.99
Execute does not insert default value for Apple Cake when using execute alone, but it works after one row is inserted through executemany because it buffers the default values.
Executemany is not a full alternative due to this another bug, which breaks trigger, but it may be a temporary work around if used on one row before using multiple execute.
https://jira.mariadb.org/browse/MDEV-24411