Class: ActiveRecord::ConnectionAdapters::Spanner::ReferenceDefinition
- Inherits:
-
ReferenceDefinition
- Object
- ReferenceDefinition
- ActiveRecord::ConnectionAdapters::Spanner::ReferenceDefinition
- Defined in:
- lib/active_record/connection_adapters/spanner/schema_definitions.rb
Instance Method Summary collapse
-
#initialize(name, polymorphic: false, index: true, foreign_key: false, type: :integer, **options) ⇒ ReferenceDefinition
constructor
This constructor intentionally does not call super to prevent ActiveRecord from creating an additional secondary index for the foreign key.
Constructor Details
#initialize(name, polymorphic: false, index: true, foreign_key: false, type: :integer, **options) ⇒ ReferenceDefinition
This constructor intentionally does not call super to prevent ActiveRecord from creating an additional secondary index for the foreign key. rubocop:disable Lint/MissingSuper
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 68 def initialize \ name, polymorphic: false, index: true, foreign_key: false, type: :integer, ** @name = name @polymorphic = polymorphic @foreign_key = foreign_key # Only add an index if there is no foreign key, as Cloud Spanner will automatically add a managed index when # a foreign key is added. @index = index unless foreign_key @type = type @options = return unless polymorphic && foreign_key raise ArgumentError, "Cannot add a foreign key to a polymorphic relation" end |