Class: XMigra::DeclarativeSupport::Table::CheckConstraint
- Inherits:
-
Constraint
- Object
- Constraint
- XMigra::DeclarativeSupport::Table::CheckConstraint
- 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
-
#expression ⇒ Object
Returns the value of attribute expression.
Attributes inherited from Constraint
Instance Method Summary collapse
- #creation_sql ⇒ Object
-
#initialize(name, constr_spec) ⇒ CheckConstraint
constructor
A new instance of CheckConstraint.
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.
278 279 280 281 282 283 |
# File 'lib/xmigra/declarative_support/table.rb', line 278 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
#expression ⇒ Object
Returns the value of attribute expression.
285 286 287 |
# File 'lib/xmigra/declarative_support/table.rb', line 285 def expression @expression end |
Instance Method Details
#creation_sql ⇒ Object
287 288 289 |
# File 'lib/xmigra/declarative_support/table.rb', line 287 def creation_sql creation_name_sql + "CHECK (#{expression})" end |