-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Description
If I create a table with foreign key constraints, and then use load! to load data that violates those foreign key constraints, I get a silent failure.
The errors work if you INSERT bad data:
using SQLite, Tables
db = SQLite.DB();
Q = q -> DBInterface.execute(db, q);
Q("PRAGMA foreign_keys=ON;");
Q("CREATE TABLE a (key INTEGER PRIMARY KEY);");
Q("CREATE TABLE b (aref INTEGER, FOREIGN KEY (aref) REFERENCES a(key));");
Q("INSERT INTO a (key) VALUES (1);");
Q("INSERT INTO b (aref) VALUES (2);");
And you get a clear error message:
ERROR: SQLiteException("FOREIGN KEY constraint failed")
Stacktrace:
[1] execute(db::SQLite.DB, stmt::SQLite._Stmt, params::NamedTuple{(), Tuple{}})
@ SQLite ~\.julia\packages\SQLite\jf6KT\src\SQLite.jl:453
...
But if you load!:
input = Tables.table(fill(2, 1, 1), header=[:aref]);
input |> SQLite.load!(db, "b", ifnotexists=false);
you get no error, but
println([v[1] for v in Q("SELECT * from b;")]);
shows that b is empty:
Any[]
Metadata
Metadata
Assignees
Labels
No labels