Support self-referencing FKs in create (#537)

This commit is contained in:
Scott Perry 2023-05-08 14:10:00 -07:00 committed by GitHub
commit 39ef137e67
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 30 additions and 0 deletions

View file

@ -813,6 +813,8 @@ class Database:
pk = hash_id
# Soundness check foreign_keys point to existing tables
for fk in foreign_keys:
if fk.other_table == name and columns.get(fk.other_column):
continue
if not any(
c for c in self[fk.other_table].columns if c.name == fk.other_column
):