dolt
dolt copied to clipboard
`dolt merge` silently violates check constraints
Repro:
dolt init
dolt sql <<SQL
CREATE TABLE t (
pk int PRIMARY KEY,
col1 int, col2 int,
CHECK (col1 != col2)
);
INSERT INTO t VALUES (1, 2, 3);
CALL DOLT_COMMIT('-am', 'insert test row');
CALL DOLT_CHECKOUT('-b', 'right');
UPDATE t SET col1 = 4 where pk = 1;
CALL DOLT_COMMIT('-am', 'update col1 to 4');
CALL DOLT_CHECKOUT('main');
UPDATE t set col2 = 4 where pk = 1;
CALL DOLT_COMMIT('-am', 'update col2 to 4');
CALL DOLT_MERGE('right');
SQL
Merge Output:
+--------------+
| no_conflicts |
+--------------+
| 1 |
+--------------+
Our constraint is violated and no errors are produced:
> SELECT * from t;
+----+------+------+
| pk | col1 | col2 |
+----+------+------+
| 1 | 4 | 4 |
+----+------+------+
Slight mod to the repro:
dolt sql <<SQL
CREATE TABLE t (
pk int PRIMARY KEY,
col1 int, col2 int,
CHECK (col1 != col2)
);
INSERT INTO t VALUES (1, 2, 3);
CALL DOLT_ADD('t');
CALL DOLT_COMMIT('-am', 'insert test row');
CALL DOLT_CHECKOUT('-b', 'right');
UPDATE t SET col1 = 4 where pk = 1;
CALL DOLT_COMMIT('-am', 'update col1 to 4');
CALL DOLT_CHECKOUT('main');
UPDATE t set col2 = 4 where pk = 1;
CALL DOLT_COMMIT('-am', 'update col2 to 4');
CALL DOLT_MERGE('right');
SQL
We do check foreign key and unique key constraints on merge.