Class: ActiveRecord::ConnectionAdapters::Spanner::TableDefinition

Inherits:
TableDefinition
  • Object
show all
Defined in:
lib/active_record/connection_adapters/spanner/schema_definitions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#interleave_in_parentObject (readonly)

Returns the value of attribute interleave_in_parent.



11
12
13
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 11

def interleave_in_parent
  @interleave_in_parent
end

Instance Method Details

#interleave_in(parent, on_delete = nil) ⇒ Object



13
14
15
16
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 13

def interleave_in parent, on_delete = nil
  @interleave_in_parent = parent
  @on_delete = on_delete
end

#interleave_in?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 22

def interleave_in?
  @interleave_in_parent != nil
end

#new_column_definition(name, type, **options) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 37

def new_column_definition name, type, **options
  case type
  when :virtual
    type = options[:type]
  end

  super
end

#on_deleteObject



26
27
28
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 26

def on_delete
  "CASCADE" if @on_delete == :cascade
end

#parent_key(name, type: nil) ⇒ Object



18
19
20
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 18

def parent_key name, type: nil
  column name, :parent_key, null: false, passed_type: type
end

#references(*args, **options) ⇒ Object Also known as: belongs_to



30
31
32
33
34
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 30

def references *args, **options
  args.each do |ref_name|
    Spanner::ReferenceDefinition.new(ref_name, **options).add_to(self)
  end
end

#valid_column_definition_optionsObject



46
47
48
# File 'lib/active_record/connection_adapters/spanner/schema_definitions.rb', line 46

def valid_column_definition_options
  super + [:type, :array, :allow_commit_timestamp, :as, :stored, :parent_key, :passed_type, :index]
end