Class: ActiveRecord::ConnectionAdapters::FirebirdColumn

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

Overview

:nodoc:

Constant Summary collapse

VARCHAR_MAX_LENGTH =
32_765
BLOB_MAX_LENGTH =
32_767

Instance Attribute Summary

Attributes inherited from Column

#limit, #name, #null, #precision, #primary, #scale, #sql_type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Column

binary_to_string, #human_name, #klass, #number?, string_to_binary, string_to_date, string_to_dummy_time, string_to_time, #text?, #type_cast, #type_cast_code, value_to_decimal

Constructor Details

#initialize(name, domain, type, sub_type, length, precision, scale, default_source, null_flag) ⇒ FirebirdColumn

Returns a new instance of FirebirdColumn.



46
47
48
49
50
51
52
53
54
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 46

def initialize(name, domain, type, sub_type, length, precision, scale, default_source, null_flag)
  @firebird_type = FireRuby::SQLType.to_base_type(type, sub_type).to_s

  super(name.downcase, nil, @firebird_type, !null_flag)

  @default = parse_default(default_source) if default_source
  @limit = decide_limit(length)
  @domain, @sub_type, @precision, @scale = domain, sub_type, precision, scale.abs
end

Class Method Details

.value_to_boolean(value) ⇒ Object



70
71
72
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 70

def self.value_to_boolean(value)
  %W(#{FirebirdAdapter.boolean_domain[:true]} true t 1).include? value.to_s.downcase
end

Instance Method Details

#defaultObject



66
67
68
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 66

def default
  type_cast(decide_default) if @default
end

#typeObject



56
57
58
59
60
61
62
63
64
# File 'lib/active_record/connection_adapters/firebird_adapter.rb', line 56

def type
  if @domain =~ /BOOLEAN/
    :boolean
  elsif @type == :binary and @sub_type == 1
    :text
  else
    @type
  end
end