mariadb 10.2 CHECK constraints don't allow NULL to pass, need to revise BOOLEAN, ENUM

Issue #4047 new
Mike Bayer repo owner created an issue

will seek reporting this upstream as this likely breaks the SQL standard:

CREATE TABLE ck_cons_test (
    -> b1 INT NULL, 
    -> b2 INT NULL,
    -> CHECK (b1 IN (0, 1)), 
    -> CHECK (b2 IN (0, 1, NULL))
    -> );
Query OK, 0 rows affected (0.03 sec)

MariaDB [test]> INSERT INTO ck_cons_test (b1, b2) VALUES (1, 0);
Query OK, 1 row affected (0.01 sec)

MariaDB [test]> 
MariaDB [test]> INSERT INTO ck_cons_test (b1, b2) VALUES (1, NULL);
ERROR 4025 (23000): CONSTRAINT `CONSTRAINT_2` failed for `test`.`ck_cons_test`
MariaDB [test]> 
MariaDB [test]> INSERT INTO ck_cons_test (b1, b2) VALUES (NULL, 0);
ERROR 4025 (23000): CONSTRAINT `CONSTRAINT_1` failed for `test`.`ck_cons_test`

Comments (2)

  1. Mike Bayer reporter
    • changed milestone to 1.2

    they're going to fix this upstream so i dont know how worth it it is to chase this one down. it will be a mess on our end to work around. a gerrit is at https://gerrit.sqlalchemy.org/#/c/479/ but this approach, if taken, should at least be limited to the affected versions of mariadb.

  2. Log in to comment