Details
-
Bug
-
Status: Closed (View Workflow)
-
Major
-
Resolution: Incomplete
-
3.3.10
-
None
-
Windows 10, MariaDB 10.6.17
Description
Following fails even when that table should allow null
|
conp2 = mariadb.connect(
|
username="root", |
password="sql", |
host="localhost", |
db="demodb", |
read_timeout=60 * 60 * 8, # 8 hours |
write_timeout=60 * 60 * 8, # 8 hours |
connect_timeout=60, # 1 minute |
client_flag=CLIENT.MULTI_STATEMENTS,
|
)
|
|
with conp2.cursor() as c:
|
c.execute("DROP TABLE IF EXISTS cakes2") |
c.execute("DROP TABLE IF EXISTS cakes") |
c.execute(
|
"""CREATE TABLE `cakes` ( |
`id` INT(11) NOT NULL AUTO_INCREMENT, |
`cake` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci', |
`price` DECIMAL(10,2) NULL, |
PRIMARY KEY (`id`) USING BTREE
|
)
|
COLLATE='utf8mb3_general_ci' |
ENGINE=InnoDB
|
AUTO_INCREMENT=3 |
;
|
""" |
)
|
c.execute(
|
"""CREATE TABLE `cakes2` ( |
`id` INT(11) NOT NULL AUTO_INCREMENT, |
`cake` VARCHAR(100) NULL DEFAULT NULL COLLATE 'utf8mb3_general_ci', |
`price` DECIMAL(10,2) NULL, |
`cakeid` INT(11) NULL DEFAULT NULL, |
PRIMARY KEY (`id`) USING BTREE,
|
|
CONSTRAINT `FK_cakes2_cakes` FOREIGN KEY (`cakeid`) REFERENCES `cakes` (`id`) ON UPDATE CASCADE ON DELETE CASCADE
|
|
)
|
COLLATE='utf8mb3_general_ci' |
ENGINE=InnoDB
|
AUTO_INCREMENT=3 |
;
|
""" |
)
|
|
sql = "INSERT INTO cakes (id, cake, price) VALUES (?,?,?)" |
cac = [(1, "Cherry Cake", 2.10), (2, "Apple Cake", INDICATOR.NULL)] |
print(cac)
|
c.executemany(sql, cac)
|
sql = "INSERT INTO cakes2 (id, cake, price, cakeid) VALUES (?,?,?,?)" |
cac = [
|
(1, "Cherry Cake", 2.10, 1), |
(2, "Apple Cake", INDICATOR.NULL, INDICATOR.NULL), |
]
|
print(cac)
|
c.executemany(sql, cac)
|
c.execute("commit") |