Method: Sequel::Postgres::DatabaseMethods#check_constraints

Defined in:
lib/sequel/adapters/shared/postgres.rb

#check_constraints(table) ⇒ Object

A hash of metadata for CHECK constraints on the table. Keys are CHECK constraint name symbols. Values are hashes with the following keys:

:definition

An SQL fragment for the definition of the constraint

:columns

An array of column symbols for the columns referenced in the constraint, can be an empty array if the database cannot deteremine the column symbols.



350
351
352
353
354
355
356
357
358
359
360
361
# File 'lib/sequel/adapters/shared/postgres.rb', line 350

def check_constraints(table)
  m = output_identifier_meth

  hash = {}
  _check_constraints_ds.where_each(:conrelid=>regclass_oid(table)) do |row|
    constraint = m.call(row[:constraint])
    entry = hash[constraint] ||= {:definition=>row[:definition], :columns=>[], :validated=>row[:validated], :enforced=>row[:enforced]}
    entry[:columns] << m.call(row[:column]) if row[:column]
  end
  
  hash
end