Class: ActiveRecord::ConnectionAdapters::SQLServerConstraint

Inherits:
AbstractTableConstraint show all
Defined in:
lib/connection_adapters/sqlserver_adapter.rb

Constant Summary

Constants inherited from AbstractTableConstraint

AbstractTableConstraint::CHECK_CONSTRAINT_TYPE, AbstractTableConstraint::FOREIGN_KEY_TYPE, AbstractTableConstraint::PRIMARY_KEY_TYPE, AbstractTableConstraint::UNIQUE_KEY_TYPE

Instance Attribute Summary

Attributes inherited from AbstractTableConstraint

#column_name, #constraint_name, #constraint_type, #member_of_composite, #referenced_column_name, #referenced_table_name, #table_name, #table_schema

Instance Method Summary collapse

Methods inherited from AbstractTableConstraint

#component_of_unique_key?, #foreign_key?, #primary_key?, #raise_subclass_responsibility_error, #unique_key?

Constructor Details

#initialize(constraint_schema, table_name, column_name, constraint_name, constraint_type, referenced_constraint_name, referenced_table_name, referenced_column_name) ⇒ SQLServerConstraint

Returns a new instance of SQLServerConstraint.



33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/connection_adapters/sqlserver_adapter.rb', line 33

def initialize(constraint_schema, table_name, column_name, constraint_name, constraint_type, 
  referenced_constraint_name, referenced_table_name, referenced_column_name)
  @table_schema = table_schema
  @table_name = table_name
  @column_name = Set.new [column_name]
  @referenced_table_name = referenced_table_name
  @referenced_column_name = referenced_column_name
  @constraint_schema = constraint_schema
  @referenced_constraint_name = referenced_constraint_name
  @constraint_name = constraint_name 
  @constraint_type = constraint_type
end

Instance Method Details

#is_foreign_constraint?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/connection_adapters/sqlserver_adapter.rb', line 51

def is_foreign_constraint?(table_name)
  @table_name.upcase != table_name.upcase
end

#is_member_of_composite?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/connection_adapters/sqlserver_adapter.rb', line 47

def is_member_of_composite?
  @column_name.size > 1
end