Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UpdateJoins don't honor check constraints on all tables #4304

Closed
fulghum opened this issue Sep 9, 2022 · 1 comment
Closed

UpdateJoins don't honor check constraints on all tables #4304

fulghum opened this issue Sep 9, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@fulghum
Copy link
Contributor

fulghum commented Sep 9, 2022

UpdateJoins only honor the check constraints of the first table being updated. If additional joined tables have check constraints, they are not included.

Repro

❯ dolt version
dolt version 0.41.0

❯ mkdir checkcheck && cd checkcheck && dolt init

❯ dolt sql << SQL
create table t1 (pk1 int primary key, constraint con1 check (pk1 > 0));
create table t2 (pk2 int primary key, constraint con2 check (pk2 < 0));
insert into t1 values(1);
insert into t2 values(-1);
update t1 join t2 set t1.pk1 = 2, t2.pk2 = 2;
select * from t1 join t2;
SQL

Rows matched: 2  Changed: 2  Warnings: 0
+-----+-----+
| pk1 | pk2 |
+-----+-----+
| 2   | 2   |
+-----+-----+
@fulghum fulghum added the bug Something isn't working label Sep 9, 2022
@timsehn
Copy link
Contributor

timsehn commented Sep 25, 2023

Seems like Jason fixed this and forgot to resolve.

$ mkdir checkcheck && cd checkcheck && dolt init
Successfully initialized dolt data repository.
$ dolt sql << SQL
create table t1 (pk1 int primary key, constraint con1 check (pk1 > 0));
create table t2 (pk2 int primary key, constraint con2 check (pk2 < 0));
insert into t1 values(1);
insert into t2 values(-1);
update t1 join t2 set t1.pk1 = 2, t2.pk2 = 2;
select * from t1 join t2;
SQL
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
error on line 5 for query 
update t1 join t2 set t1.pk1 = 2, t2.pk2 = 2: Check constraint "con2" violated

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants