Class: ActiveRecord::ConnectionAdapters::IBM_DB2Constraint

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

Constant Summary collapse

ISERIES_PRIMARY_KEY_TYPE =
"P"
ISERIES_FOREIGN_KEY_TYPE =
"F"
ISERIES_UNIQUE_KEY_TYPE =
"U"
ISERIES_CHECK_CONSTRAINT_TYPE =
"C"

Constants inherited from AbstractTableConstraint

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

Instance Attribute Summary collapse

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

#raise_subclass_responsibility_error, #unique_key?

Constructor Details

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

Returns a new instance of IBM_DB2Constraint.



144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 144

def initialize(constraint_schema, constraint_name, constraint_type, table_name, column_name,
  referenced_constraint_name, referenced_table_name, referenced_column_name, delete_rule)
  @constraint_schema = constraint_schema
  @constraint_name = constraint_name
  @table_name = table_name
  @constraint_type = constraint_type
  if !column_name.nil? then @column_name = Set.new [column_name.downcase] end
  @referenced_table_name = referenced_table_name
  @referenced_constraint_name = referenced_constraint_name
  @delete_rule = delete_rule
  if !referenced_column_name.nil? then @referenced_column_name = referenced_column_name.downcase end
end

Instance Attribute Details

#delete_ruleObject (readonly)

Returns the value of attribute delete_rule.



137
138
139
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 137

def delete_rule
  @delete_rule
end

#referenced_constraint_nameObject (readonly)

Returns the value of attribute referenced_constraint_name.



137
138
139
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 137

def referenced_constraint_name
  @referenced_constraint_name
end

#update_ruleObject (readonly)

Returns the value of attribute update_rule.



137
138
139
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 137

def update_rule
  @update_rule
end

Instance Method Details

#component_of_unique_key?Boolean

Returns:

  • (Boolean)


165
166
167
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 165

def component_of_unique_key?
  constraint_type == UNIQUE_KEY_TYPE || constraint_type == ISERIES_UNIQUE_KEY_TYPE
end

#foreign_key?Boolean

Returns:

  • (Boolean)


161
162
163
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 161

def foreign_key?
  constraint_type == FOREIGN_KEY_TYPE || constraint_type == ISERIES_FOREIGN_KEY_TYPE
end

#is_foreign_constraint?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


173
174
175
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 173

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

#is_member_of_composite?Boolean

Returns:

  • (Boolean)


169
170
171
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 169

def is_member_of_composite?
  @column_name.size > 1
end

#primary_key?Boolean

Returns:

  • (Boolean)


157
158
159
# File 'lib/connection_adapters/ibm_db2_adapter.rb', line 157

def primary_key?
  constraint_type == PRIMARY_KEY_TYPE || constraint_type == ISERIES_PRIMARY_KEY_TYPE
end