Class: ActiveRecord::ConnectionAdapters::AbstractTableConstraint
- Inherits:
-
Object
- Object
- ActiveRecord::ConnectionAdapters::AbstractTableConstraint
- 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
Direct Known Subclasses
IBM_DB2Constraint, MysqlConstraint, OracleConstraint, PostgreSQLConstraint, SQLServerConstraint
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
-
#column_name ⇒ Object
readonly
Returns the value of attribute column_name.
-
#constraint_name ⇒ Object
readonly
Returns the value of attribute constraint_name.
-
#constraint_type ⇒ Object
readonly
Returns the value of attribute constraint_type.
-
#member_of_composite ⇒ Object
writeonly
Sets the attribute member_of_composite.
-
#referenced_column_name ⇒ Object
readonly
Returns the value of attribute referenced_column_name.
-
#referenced_table_name ⇒ Object
readonly
Returns the value of attribute referenced_table_name.
-
#table_name ⇒ Object
readonly
Returns the value of attribute table_name.
-
#table_schema ⇒ Object
readonly
Returns the value of attribute table_schema.
Instance Method Summary collapse
- #component_of_unique_key? ⇒ Boolean
- #foreign_key? ⇒ Boolean
- #is_member_of_composite? ⇒ Boolean
- #primary_key? ⇒ Boolean
- #raise_subclass_responsibility_error ⇒ Object (also: #initialize, #is_foreign_constraint?)
- #unique_key? ⇒ Boolean
Instance Attribute Details
#column_name ⇒ Object (readonly)
Returns the value of attribute column_name.
14 15 16 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 14 def column_name @column_name end |
#constraint_name ⇒ Object (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_type ⇒ Object (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 |
#member_of_composite=(value) ⇒ Object (writeonly)
Sets the attribute member_of_composite
17 18 19 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 17 def member_of_composite=(value) @member_of_composite = value end |
#referenced_column_name ⇒ Object (readonly)
Returns the value of attribute referenced_column_name.
14 15 16 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 14 def referenced_column_name @referenced_column_name end |
#referenced_table_name ⇒ Object (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_name ⇒ Object (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_schema ⇒ Object (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
#component_of_unique_key? ⇒ Boolean
34 35 36 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 34 def component_of_unique_key? constraint_type == UNIQUE_KEY_TYPE end |
#foreign_key? ⇒ Boolean
30 31 32 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 30 def foreign_key? constraint_type == FOREIGN_KEY_TYPE end |
#is_member_of_composite? ⇒ Boolean
42 43 44 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 42 def is_member_of_composite? @member_of_composite ? @member_of_composite : false end |
#primary_key? ⇒ 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_error ⇒ Object Also known as: initialize, is_foreign_constraint?
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
38 39 40 |
# File 'lib/connection_adapters/abstract_adapter.rb', line 38 def unique_key? component_of_unique_key? and !is_member_of_composite? end |