On Wed, Oct 28, 2020 at 1:05 PM Rodrigo Dutra <[email protected]> wrote:
> This :
> add_constraint({name: :tip_not_null, valid: false}, Sequel.~(tip: nil))
> Generates this :
> ALTER TABLE "orders" ADD CONSTRAINT "tip_not_null" CHECK ('CHECK (`tip` IS
> NOT NULL) NOT VALID')
> which it weirdly adds some extra check in there
>
The option for NOT VALID is {:not_valid: true}, not {valid: false}. See
http://sequel.jeremyevans.net/rdoc/files/doc/postgresql_rdoc.html#label-Adding+Foreign+Key+and+Check+Constraints+Without+Initial+Validation
I can't reproduce the issue with duplicated CHECKS:
DB.alter_table(:x){add_constraint({name: :tip_not_null, not_valid: true},
Sequel.~(tip: nil))}
# ALTER TABLE "x" ADD CONSTRAINT "tip_not_null" CHECK ("tip" IS NOT NULL)
NOT VALID
Thanks,
Jeremy
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSSd8D9iTjVyQTQRFc-QMLtso%3D5gn4uLxMEjvy9yYpMC4MQ%40mail.gmail.com.