class ActiveRecordSpannerAdapter::Table::Column

Attributes

allow_commit_timestamp[RW]
default[RW]
limit[RW]
name[RW]
nullable[W]
ordinal_position[RW]
primary_key[RW]
table_name[RW]
type[RW]

Public Class Methods

new(\ table_name, name, type, limit: nil, ordinal_position: nil, nullable: true, allow_commit_timestamp: nil, default: nil) click to toggle source
# File lib/activerecord_spanner_adapter/table/column.rb, line 14
def initialize \
    table_name,
    name,
    type,
    limit: nil,
    ordinal_position: nil,
    nullable: true,
    allow_commit_timestamp: nil,
    default: nil
  @table_name = table_name.to_s
  @name = name.to_s
  @type = type
  @limit = limit
  @nullable = nullable != false
  @ordinal_position = ordinal_position
  @allow_commit_timestamp = allow_commit_timestamp
  @default = default
  @primary_key = false
end

Public Instance Methods

nullable() click to toggle source
# File lib/activerecord_spanner_adapter/table/column.rb, line 34
def nullable
  return false if primary_key
  @nullable
end
options() click to toggle source
# File lib/activerecord_spanner_adapter/table/column.rb, line 44
def options
  {
    limit: limit,
    null: nullable,
    allow_commit_timestamp: allow_commit_timestamp
  }.delete_if { |_, v| v.nil? }
end
spanner_type() click to toggle source
# File lib/activerecord_spanner_adapter/table/column.rb, line 39
def spanner_type
  return "#{type}(#{limit || 'MAX'})" if limit_allowed?
  type
end

Private Instance Methods

limit_allowed?() click to toggle source
# File lib/activerecord_spanner_adapter/table/column.rb, line 54
def limit_allowed?
  ["BYTES", "STRING"].include? type
end