[DBIx-Class-Devel] [sql-translator] Honour DEFERRABLE on all constraints in PostgreSQL (#75)

Alastair McGowan-Douglas notifications at github.com
Tue Nov 3 11:09:21 GMT 2015


The docs quoted by the PostgreSQL provider say that all constraints can be deferrable.

https://metacpan.org/pod/SQL::Translator::Producer::PostgreSQL#PostgreSQL-Create-Table-Syntax

However, if we just shove DEFERRABLE on everything, most things will break, because a deferrable primary key cannot be used in someone else's foreign key.

After some discussion in #dbix-class we decided it would suffice to change the DEFERRABLE default so that it is true for foreign keys, but false otherwise. This mimics the existing behaviour, while still allowing for the new behaviour to be specified.

I've fixed the tests to allow for this change, but I've not extended them to look for it.
You can view, comment on, or merge this pull request online at:

  https://github.com/dbsrgits/sql-translator/pull/75

-- Commit Summary --

  * Honour the deferred flag on *all* constraints
  * Set deferrable default to 1 for FK, 0 otherwise
  * Set deferrable lazy, so default can see type attribute
  * Special-case the default deferrable value in tests
  * Fix all tests where deferrable has become relevant

-- File Changes --

    M lib/SQL/Translator/Producer/PostgreSQL.pm (5)
    M lib/SQL/Translator/Schema/Constraint.pm (12)
    M lib/Test/SQL/Translator.pm (7)
    M t/17sqlfxml-producer.t (4)
    M t/23json.t (8)
    M t/24yaml.t (8)
    M t/39-filter-globals.t (2)
    M t/data/diff/pgsql/create1.yml (6)
    M t/data/diff/pgsql/create2.yml (8)
    M t/data/template/testresult_basic.txt (8)
    M t/data/xml/schema.xml (8)

-- Patch Links --

https://github.com/dbsrgits/sql-translator/pull/75.patch
https://github.com/dbsrgits/sql-translator/pull/75.diff

---
Reply to this email directly or view it on GitHub:
https://github.com/dbsrgits/sql-translator/pull/75
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.scsys.co.uk/pipermail/dbix-class-devel/attachments/20151103/addfcf0c/attachment.htm>


More information about the DBIx-Class-Devel mailing list