dont validate fkey on parent add tests

correct msitake and add null test issue

add fkey test
This commit is contained in:
Pavan-Nambi
2025-11-16 08:54:15 +05:30
parent 8edea305f6
commit 3de37d3f64
3 changed files with 32 additions and 2 deletions

View File

@@ -968,8 +968,6 @@ impl Schema {
None
} else {
find_parent_unique(&parent_cols)
.ok_or_else(|| fk_mismatch_err(&child.name, &parent_tbl.name))?
.into()
};
fk.validate()?;
out.push(ResolvedFkRef {

View File

@@ -1207,3 +1207,34 @@ do_execsql_test_in_memory_any_error fk-update-parent-multi-col-pk-2 {
INSERT INTO child VALUES(1, 2);
UPDATE parent SET b = 3 WHERE a = 1 AND b = 2;
}
# https://github.com/tursodatabase/turso/issues/3965
do_execsql_test_on_specific_db {:memory:} fk-no-val-on-parent {
PRAGMA foreign_keys=ON;
CREATE TABLE t1(
a INT,
b INT
);
CREATE TABLE t2(
x INT,
y INT,
FOREIGN KEY (x, y) REFERENCES t1(a, b)
);
INSERT INTO t1(a, b) VALUES (5, 10);
SELECT * FROM t1;
} {5|10}
do_execsql_test_in_memory_any_error fk-val-on-parent {
PRAGMA foreign_keys=ON;
CREATE TABLE t1(
a INT,
b INT
);
CREATE TABLE t2(
x INT,
y INT,
FOREIGN KEY (x, y) REFERENCES t1(a, b)
);
INSERT INTO t2(a, b) VALUES (5, 10);
SELECT * FROM t2;
}

View File

@@ -27,6 +27,7 @@ do_execsql_test sel-false {
select false;
} {0}
# https://github.com/tursodatabase/turso/issues/3966
do_execsql_test_on_specific_db {:memory:} not-null-just-cuz-unique {
create table t (a int, x int unique);
insert into t(a) values(1);