Path: | doc/release_notes/5.8.0.txt |
Last Update: | Sat Jun 02 02:04:22 +0000 2018 |
The following constraint violation types are recognized and supported:
In the cases where the plugin cannot determine an appropriate validation failure for the constraint violation, it just reraises the original exception.
This plugin is not intended as a replacement for other validations, it is intended as a last resort. The purpose of validations is to provide nice error messages for the user, and the error messages generated by this plugin are fairly generic. The error messages can be customized using the :messages plugin option, but there is only a single message used per constraint type.
DB.create_table(:foo) do Integer :i Integer :j constraint(:ic, Sequel[:i] > 2) constraint(:jc, Sequel[:j] > 2) constraint(:ijc, Sequel[:i] - Sequel[:j] > 2) end DB.check_constraints(:foo) # => { # :ic=>{:definition=>"CHECK ((i > 2))", :columns=>[:i]}, # :jc=>{:definition=>"CHECK ((j > 2))", :columns=>[:j]}, # :ijc=>{:definition=>"CHECK (((i - j) > 2))", :columns=>[:i, :j]} # }
DB.create_table!(:a) do primary_key :id Integer :i Integer :j foreign_key :a_id, :a, :foreign_key_constraint_name=>:a_a unique [:i, :j] end DB.create_table!(:b) do foreign_key :a_id, :a, :foreign_key_constraint_name=>:a_a Integer :c Integer :d foreign_key [:c, :d], :a, :key=>[:j, :i], :name=>:a_c_d end DB.foreign_key_list(:a, :reverse=>true) # => [ # {:name=>:a_a, :columns=>[:a_id], :key=>[:id], :on_update=>:no_action, # :on_delete=>:no_action, :deferrable=>false, :table=>:a, :schema=>:public}, # {:name=>:a_a, :columns=>[:a_id], :key=>[:id], :on_update=>:no_action, # :on_delete=>:no_action, :deferrable=>false, :table=>:b, :schema=>:public}, # {:name=>:a_c_d, :columns=>[:c, :d], :key=>[:j, :i], :on_update=>:no_action, # :on_delete=>:no_action, :deferrable=>false, :table=>:b, :schema=>:public} # ]
DB[:t1].insert(DB[:t2].with(DB[:t3]))