Skip to content

ALTER TABLE ... ADD COLUMN ignores REFERENCES clause #3887

@LeMikaelF

Description

@LeMikaelF

This issue is also the same as #3882, but the immediate fix isn't the same. In this case, we should support adding a FK (in the other it's a currently-unsupported feature).

Turso:

turso> create table t(a);
create table s(a);
alter table s add column b references t(a);
select * from sqlite_schema;

┌───────┬──────┬──────────┬──────────┬───────────────────────┐
│ type  │ name │ tbl_name │ rootpage │ sql                   │
├───────┼──────┼──────────┼──────────┼───────────────────────┤
│ table │ t    │ t        │        2 │ CREATE TABLE t (a)    │
├───────┼──────┼──────────┼──────────┼───────────────────────┤
│ table │ s    │ s        │        3 │ CREATE TABLE s (a, b) │
└───────┴──────┴──────────┴──────────┴───────────────────────┘

SQLite:

sqlite> create table t(a);
sqlite> create table s(a);
sqlite> alter table s add column b references t(a);
sqlite> select * from sqlite_schema;
table|t|t|2|CREATE TABLE t(a)
table|s|s|3|CREATE TABLE s(a, b references t(a))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions