Class: Mkxms::Mssql::UniqueConstraintHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/mkxms/mssql/unique_constraint_handler.rb

Instance Method Summary collapse

Constructor Details

#initialize(constraints, node) ⇒ UniqueConstraintHandler

Returns a new instance of UniqueConstraintHandler.



15
16
17
18
19
20
21
# File 'lib/mkxms/mssql/unique_constraint_handler.rb', line 15

def initialize(constraints, node)
  a = node.attributes
  
  @uconst = UniqueConstraint.new(a).tap do |c|
    constraints << c
  end
end

Instance Method Details

#handle_column_element(parse) ⇒ Object



23
24
25
26
27
28
# File 'lib/mkxms/mssql/unique_constraint_handler.rb', line 23

def handle_column_element(parse)
  a = parse.node.attributes
  
  raise UnsupportedFeatureError.new("Unique constraints may not specify included columns (#{@uconst.qualified_table})") if a['included']
  @uconst.columns << IndexColumn.new(a['name'], a['desc'] ? :descending : :ascending)
end