Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Self referencing foreign keys unsupported #170

Open
benkilimnik opened this issue May 9, 2023 · 1 comment
Open

Self referencing foreign keys unsupported #170

benkilimnik opened this issue May 9, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@benkilimnik
Copy link
Member

benkilimnik commented May 9, 2023

Encountered in the sample application schema for commento located in experiments/schema-annot/annotated/commento-annotated.sql

In the table comments we would like to have a self referencing foreign key on the column parentHex with ACCESSED_BY to support deletion of the row when the parent comment given by parentHex is deleted.

CREATE TABLE comments ( \
  commentHex TEXT NOT NULL UNIQUE PRIMARY KEY, \
  domain TEXT NOT NULL, \
  path TEXT NOT NULL, \
  commenterHex TEXT NOT NULL, \
  parentHex TEXT NOT NULL, \
  score INTEGER NOT NULL, \
  state TEXT NOT NULL, \
  FOREIGN KEY (commenterHex) OWNED_BY commenters(commenterHex), \
  FOREIGN KEY (domain) ACCESSED_BY domains(domain), \
  ON DEL parentHex DELETE_ROW, \
  FOREIGN KEY (parentHex) ACCESSED_BY comments(parentHex), \ -- > throws error
  ON GET parentHex ANON (commenterHex, score, state), \
  ON GET domain ANON (commenterHex, score, state) \
);

K9db throws this error:

INVALID_ARGUMENT: FK points to nonexisting table
@benkilimnik benkilimnik added the bug Something isn't working label May 10, 2023
@KinanBab
Copy link
Collaborator

This is now supported for ACCESSED_BY

ACCESSES, OWNED_BY, OWNS are not support yet.

@KinanBab KinanBab added enhancement New feature or request and removed bug Something isn't working labels May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants