Class: ActiveRecord::ConnectionAdapters::AbstractTableConstraint

Inherits:
Object
  • Object
show all
Defined in:
lib/connection_adapters/abstract_adapter.rb

Overview

This is abstract class serves as the template for table constraints from all databases compatible with the ISO SQL:2003 information schema standard

Constant Summary collapse

PRIMARY_KEY_TYPE =
"PRIMARY KEY"
FOREIGN_KEY_TYPE =
"FOREIGN KEY"
UNIQUE_KEY_TYPE =
"UNIQUE"
CHECK_CONSTRAINT_TYPE =
"CHECK"

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#column_namesObject (readonly)

Returns the value of attribute column_names.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def column_names
  @column_names
end

#constraint_nameObject (readonly)

Returns the value of attribute constraint_name.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def constraint_name
  @constraint_name
end

#constraint_typeObject (readonly)

Returns the value of attribute constraint_type.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def constraint_type
  @constraint_type
end

#referenced_column_namesObject (readonly)

Returns the value of attribute referenced_column_names.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def referenced_column_names
  @referenced_column_names
end

#referenced_table_nameObject (readonly)

Returns the value of attribute referenced_table_name.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def referenced_table_name
  @referenced_table_name
end

#table_nameObject (readonly)

Returns the value of attribute table_name.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def table_name
  @table_name
end

#table_schemaObject (readonly)

Returns the value of attribute table_schema.



14
15
16
# File 'lib/connection_adapters/abstract_adapter.rb', line 14

def table_schema
  @table_schema
end

Instance Method Details

#foreign_key?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/connection_adapters/abstract_adapter.rb', line 30

def foreign_key?
  constraint_type == FOREIGN_KEY_TYPE
end

#primary_key?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/connection_adapters/abstract_adapter.rb', line 26

def primary_key?
  constraint_type == PRIMARY_KEY_TYPE
end

#raise_subclass_responsibility_errorObject Also known as: initialize, is_foreign_constraint?

Raises:

  • (NotImplementedError)


19
20
21
# File 'lib/connection_adapters/abstract_adapter.rb', line 19

def raise_subclass_responsibility_error
  raise NotImplementedError, "AbstractTableConstraint subclass #{self.class} did not implement this method"
end

#unique_key?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/connection_adapters/abstract_adapter.rb', line 34

def unique_key?
  constraint_type == UNIQUE_KEY_TYPE
end