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

foreign key update and delete actions are not reflected in pg_constraint table #34862

Closed
AlexMesser opened this issue Feb 13, 2019 · 4 comments
Closed
Assignees
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@AlexMesser
Copy link

AlexMesser commented Feb 13, 2019

FK's update and delete actions works fine, but not reflected in pg_constraint table.

Steps to reproduce:

CREATE TABLE "foo" ("id" INT PRIMARY KEY)

CREATE TABLE "bar" ("id" INT PRIMARY KEY, "fooId" INT)

CREATE INDEX "idx_fooId" ON "bar" ("fooId") 

ALTER TABLE "bar" 
     ADD CONSTRAINT "fk_foo_bar" 
     FOREIGN KEY ("fooId") REFERENCES "foo"("id") 
     ON UPDATE SET NULL
     ON DELETE SET NULL

SELECT "conname", "confupdtype", "confdeltype" FROM "pg_constraint"

results:

conname confupdtype confdeltype
fk_foo_bar a a

from the postgres docs:
confupdtype - Foreign key update action code: a = no action, r = restrict, c = cascade, n = set null, d = set default
confdeltype - Foreign key deletion action code: a = no action, r = restrict, c = cascade, n = set null, d = set default

@BramGruneir BramGruneir assigned BramGruneir and unassigned knz Feb 14, 2019
@BramGruneir
Copy link
Member

Should be an easy fix, I'll take it on.

@knz knz added A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. labels Feb 14, 2019
@knz
Copy link
Contributor

knz commented Feb 14, 2019

@BramGruneir thanks :)

@knz
Copy link
Contributor

knz commented Feb 19, 2019

Fixing in #35052

@knz
Copy link
Contributor

knz commented Feb 20, 2019

@AlexMesser we're fixing this in the master branch. @awoods187 does the fix need to be ported back to 2.1 too?

craig bot pushed a commit that referenced this issue Feb 20, 2019
35052: sql: fix conupdtype, confdeltype, conmatchtype in pg_constraint r=knz a=knz

Fixes #34862. For TypeORM compat. cc @awoods187 


Co-authored-by: Raphael 'kena' Poss <[email protected]>
@craig craig bot closed this as completed in #35052 Feb 20, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-vtables Virtual tables - pg_catalog, information_schema etc C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

No branches or pull requests

3 participants