Method: ActiveRecord::ConnectionAdapters::NuoDBColumn#initialize

Defined in:
lib/active_record/connection_adapters/nuodb_adapter.rb

#initialize(name, default, sql_type = nil, null = true, length = nil, precision = nil, scale = nil, options = {}) ⇒ NuoDBColumn

Returns a new instance of NuoDBColumn.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/active_record/connection_adapters/nuodb_adapter.rb', line 61

def initialize(name, default, sql_type = nil, null = true, length = nil, precision = nil, scale = nil, options = {})
  @options = options.symbolize_keys

  @name      = name
  @null      = null

  # NuoDB stores fixed point decimal values as 'bigint'
  # Examine the scale to determine the type
  if precision > 0 && sql_type == 'bigint'
    @sql_type  = 'decimal'
    @type      = :decimal
    @precision = precision
    @scale     = scale
  else
    @sql_type  = sql_type
    @type      = simplified_type(sql_type)
    @precision = nil
    @scale     = nil
  end

  # Limit only applies to :string, :text, :binary, and :integer
  # See http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/TableDefinition.html
  if @type =~ /^(string|text|binary|integer)$/ && @sql_type != 'string'
    @limit     = length
  else
    @limit     = nil
  end

  @default   = extract_default(default)
  @primary   = @options[:is_identity] || @options[:is_primary]
  @coder     = nil
end