Git Product home page Git Product logo

Comments (8)

s-takehana avatar s-takehana commented on June 10, 2024 1

Thank you for your infromation.

The cause of this issue is referential actions.

Stack Overflow
PostgreSQL doc

Referential actions other than the NO ACTION check cannot be deferred, even if the constraint is declared deferrable.

In the NO ACTION case, I've confirmed to be deferred whithout DEFERRABLE.

from testfixtures.

andreynering avatar andreynering commented on June 10, 2024

Maybe it's an issue with PostgreSQL 10? Until now, I only tried with PosgreSQL 9.x and it worked.

from testfixtures.

andreynering avatar andreynering commented on June 10, 2024

Also, you can try checking the permissions of this user. Does this user has permission to alter constraints?

from testfixtures.

s-takehana avatar s-takehana commented on June 10, 2024

I can execute ALTER CONSTRAINT by non-superuser.
I'll try PostgreSQL 9.

USER=> ALTER TABLE "public"."environments" ALTER CONSTRAINT "environments_created_by_users_id_foreign" DEFERRABLE;
ALTER TABLE
USER=> BEGIN;
BEGIN
USER=> SET CONSTRAINTS ALL DEFERRED;
SET CONSTRAINTS
USER=> DELETE FROM "public"."users";
ERROR:  update or delete on table "users" violates foreign key constraint "environments_created_by_users_id_foreign" on table "environments"
DETAIL:  Key (id)=(1) is still referenced from table "environments".
USER=> COMMIT;
ROLLBACK
USER=> ALTER TABLE "public"."environments" ALTER CONSTRAINT "environments_created_by_users_id_foreign" NOT DEFERRABLE;
ALTER TABLE

from testfixtures.

s-takehana avatar s-takehana commented on June 10, 2024

I've tried PostgreSQL 9.6.6. The result is the same.

Does ALTER CONSTRAINT approach require to create CONSTRAINT with DEFERRABLE ?
It worked fine.

    CONSTRAINT aaaaa FOREIGN KEY ("user")
        REFERENCES public.users (id) MATCH SIMPLE
        ON UPDATE NO ACTION
        ON DELETE NO ACTION
        DEFERRABLE

from testfixtures.

andreynering avatar andreynering commented on June 10, 2024

Does ALTER CONSTRAINT approach require to create CONSTRAINT with DEFERRABLE?

Yes, it does. We just found a missing information on README.

from testfixtures.

s-takehana avatar s-takehana commented on June 10, 2024

I see. Thank you.

from testfixtures.

andreynering avatar andreynering commented on June 10, 2024

Does ALTER CONSTRAINT approach require to create CONSTRAINT with DEFERRABLE?

Yes, it does. We just found a missing information on README.

Sorry, I was wrong. The package should temporarely make NON DEFERRABLE constraints DEFERRABLE to make it work. So this should not be the issue.

from testfixtures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    šŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. šŸ“ŠšŸ“ˆšŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ā¤ļø Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.