You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite #2663
A composite foreign key with NULL in some, but not all, of its columns is rejected. SQL's default rule (MATCH SIMPLE), and SQLite, skip the check as soon as any column is NULL.
Reproduced on develop, compared with SQLite 3.43 (PRAGMA foreign_keys=ON):
CREATETABLEp (a INT, b INT, PRIMARY KEY (a, b));
INSERT INTO p VALUES (1, 1);
CREATETABLEc (x INT, y INT, FOREIGN KEY (x, y) REFERENCES p (a, b));
INSERT INTO c VALUES (1, NULL);
-- AlaSQL: Invalid foreign key on table undefined-- SQLite: inserted
The message also names the table undefined: it reads table.tableid, and the table object has no tableid. The same applies to the error at CREATE TABLE when a foreign key names more referenced columns than its own.
Direction
Skip the check when any column of the foreign key is NULL. Use the table's name in both messages.
This turns a wrong error into the right result, so it can go into 4.x.
changed the title [-]Composite foreign key with NULL in some columns is rejected, and the error names the table undefined[/-][+]Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite (5.0)[/+]on Oct 20, 2026
Decided 2026-10-20: the error message part (table name instead of undefined) goes into 4.x with #2664. Accepting NULL in some columns (MATCH SIMPLE) is a breaking change: today partial keys are refused on purpose (test807), and people can rely on that. It goes to 5.0. Way back: a CHECK that refuses a partial key.
changed the title [-]Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite (5.0)[/-][+]Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite[/+]on Oct 21, 2026
Activity
[-]Composite foreign key with NULL in some columns is rejected, and the error names the table undefined[/-][+]Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite (5.0)[/+]mathiasrw commentedon Oct 20, 2026
Decided 2026-10-20: the error message part (table name instead of
undefined) goes into 4.x with #2664. Accepting NULL in some columns (MATCH SIMPLE) is a breaking change: today partial keys are refused on purpose (test807), and people can rely on that. It goes to 5.0. Way back: aCHECKthat refuses a partial key.[-]Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite (5.0)[/-][+]Composite foreign key with NULL in some columns: MATCH SIMPLE as SQLite[/+]