dolthub / dolthub/doltgresql

Foreign keys not working with non-local tables

Open
#3,103 3 comments 0 reactions 1 assignee Claimed by @zachmu View on GitHub
customer issue
Dominant language
Go
Stars
2.1k
Forks
73
Avg merge
1d 10h
Merged PRs (30d)
129

Description

Foreign keys cannot currently reference a non-local table. Unclear at the moment whether this bug exists in Dolt as well.

```sql
CREATE TABLE bug4_parent (id integer PRIMARY KEY, v text);
CREATE TABLE bug4_child (id integer PRIMARY KEY, parent_id integer, v text);
ALTER TABLE bug4_child ADD CONSTRAINT bug4_fk FOREIGN KEY (parent_id) REFERENCES bug4_parent(id);
SELECT dolt_add('-A');
SELECT dolt_commit('--all', '--message', 'base', '--author', 'A '); -- succeeds

INSERT INTO dolt.dolt_nonlocal_tables (table_name, target_ref, options)
VALUES ('bug4_parent', 'main', 'immediate');
SELECT dolt_add('-A'); -- succeeds
SELECT dolt_commit('--all', '--message', 'nonlocal', '--author', 'A '); -- ERROR: table not found
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.