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

ERRO[0002] Getting constraints failed #36

Closed
lnschroeder opened this issue May 24, 2023 · 3 comments · Fixed by #37
Closed

ERRO[0002] Getting constraints failed #36

lnschroeder opened this issue May 24, 2023 · 3 comments · Fixed by #37

Comments

@lnschroeder
Copy link
Contributor

When using this minimal schema:

CREATE TABLE
    main (
        id text PRIMARY KEY
    );

CREATE TABLE
    sub1 (
        id text PRIMARY KEY,
        CONSTRAINT cons_name FOREIGN KEY (id) REFERENCES main (id)
    );

CREATE TABLE
    sub2 (
        id text PRIMARY KEY,
        CONSTRAINT cons_name FOREIGN KEY (id) REFERENCES main (id)
    );

I get the following error:

Getting columns and constraints
ERRO[0002] Getting constraints failed | 
ERROR: more than one row returned by a subquery used as an expression (SQLSTATE 21000) 
ERRO[0002] 
ERROR: more than one row returned by a subquery used as an expression (SQLSTATE 21000) 

The error does not occur when:

  • the constraint names cons_name for the sub1 and sub2 are different or
  • at least one of the id's of the sub tables is not declared as PRIMARY KEY (i.e. sub2 (id text, ...))

Tested on version: v0.7.1

@lnschroeder
Copy link
Contributor Author

FYI: I am using Postgres, where the constraint names do not have to unique:

Because PostgreSQL does not require constraint names to be unique within a schema (but only per-table), it is possible that there is more than one match for a specified constraint name. In this case SET CONSTRAINTS will act on all matches. For a non-schema-qualified name, once a match or matches have been found in some schema in the search path, schemas appearing later in the path are not searched.

https://www.postgresql.org/docs/current/sql-set-constraints.html

@KarnerTh
Copy link
Owner

Thanks for the ticket and the detailed description - I will have a look!

@KarnerTh
Copy link
Owner

The fix is available in version 0.8.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants