Skip to content

postgres: Disabling foreign key constraints outside of transaction throws warning #19474

Description

@othercorey

Description

Setting constraints is only valid inside a transaction which configures when the key constraints are applied - immediate or deferred.

When we disable/enable constraints, postgres throws a WARNING:

WARNING:  SET CONSTRAINTS can only be used in transaction blocks

A solution for this would be simply not emitting the SQL if we're not inside a transaction.

It seems cake has a feature enum that would cover this that's set to false for postgres:

 DriverFeatureEnum::DISABLE_CONSTRAINT_WITHOUT_TRANSACTION => false,

CakePHP Version

5.4

PHP Version

8.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions