Class: XMigra::DeclarativeSupport::Table::CheckConstraint

Inherits:
Constraint show all
Defined in:
lib/xmigra/declarative_support/table.rb

Constant Summary collapse

IDENTIFIER =
'check'
IMPLICIT_PREFIX =
'CK_'

Constants inherited from Constraint

XMigra::DeclarativeSupport::Table::Constraint::SUBTYPES

Instance Attribute Summary collapse

Attributes inherited from Constraint

#name

Instance Method Summary collapse

Methods inherited from Constraint

bad_spec, #constraint_type, deserialize, each_type, implicit_type, inherited, #only_on_column_at_creation?, type_by_identifier

Constructor Details

#initialize(name, constr_spec) ⇒ CheckConstraint

Returns a new instance of CheckConstraint.



272
273
274
275
276
277
# File 'lib/xmigra/declarative_support/table.rb', line 272

def initialize(name, constr_spec)
  super(name, constr_spec)
  @expression = constr_spec['verify'] || Constraint.bad_spec(
    %Q{Check constraint #{name} does not specify an expression to "verify"}
  )
end

Instance Attribute Details

#expressionObject

Returns the value of attribute expression.



279
280
281
# File 'lib/xmigra/declarative_support/table.rb', line 279

def expression
  @expression
end

Instance Method Details

#creation_sqlObject



281
282
283
# File 'lib/xmigra/declarative_support/table.rb', line 281

def creation_sql
  creation_name_sql + "CHECK (#{expression})"
end