Class: ActiveRecord::ConnectionAdapters::RdbColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/active_record/connection_adapters/rdb_column.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, default, sql_type_metadata = nil, null = true, table_name = nil, rdb_options = {}) ⇒ RdbColumn

Returns a new instance of RdbColumn.



25
26
27
28
29
30
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 25

def initialize(name, default,  = nil, null = true, table_name = nil, rdb_options = {})
  @domain, @sub_type = rdb_options.values_at(:domain, :sub_type)
  name = name.dup
  name.downcase!
  super(name, parse_default(default), , null, table_name)
end

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



23
24
25
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 23

def domain
  @domain
end

#sub_typeObject (readonly)

Returns the value of attribute sub_type.



23
24
25
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 23

def sub_type
  @sub_type
end

Class Method Details

.sql_type_for(field) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 5

def sql_type_for(field)
  sql_type = field[:sql_type]
  sub_type = field[:sql_subtype]

  sql_type << case sql_type
              when /(numeric|decimal)/i
                "(#{field[:precision]},#{field[:scale].abs})"
              when /(int|float|double|char|varchar|bigint)/i
                "(#{field[:length]})"
              else
                ''
              end

  sql_type << ' sub_type text' if /blob/i.match?(sql_type) && sub_type == 1
  sql_type
end

Instance Method Details

#limitObject



48
49
50
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 48

def limit
  @sql_type_metadata[:limit]
end

#precisionObject



40
41
42
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 40

def precision
  @sql_type_metadata[:precision]
end

#scaleObject



44
45
46
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 44

def scale
  @sql_type_metadata[:scale]
end

#sql_typeObject



32
33
34
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 32

def sql_type
  @sql_type_metadata[:sql_type]
end

#typeObject



36
37
38
# File 'lib/active_record/connection_adapters/rdb_column.rb', line 36

def type
  @sql_type_metadata[:type]
end