class ActiveRecord::ConnectionAdapters::NuoDBColumn
Public Class Methods
binary_to_string(value)
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 100 def binary_to_string(value) value =~ /[^[:xdigit:]]/ ? value : [value].pack('H*') end
new(name, default, sql_type = nil, null = true, length = nil, precision = nil, scale = nil, options = {})
click to toggle source
# 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
string_to_binary(value)
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 96 def string_to_binary(value) "0x#{value.unpack("H*")[0]}" end
Public Instance Methods
default_function()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 134 def default_function @options[:default_function] end
is_identity?()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 106 def is_identity? @options[:is_identity] end
is_integer?()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 118 def is_integer? !!(@sql_type =~ /int/i) end
is_primary?()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 110 def is_primary? @options[:is_primary] end
is_real?()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 122 def is_real? !!(@sql_type =~ /real/i) end
is_utf8?()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 114 def is_utf8? !!(@sql_type =~ /nvarchar|ntext|nchar/i) end
sql_type_for_statement()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 126 def sql_type_for_statement if is_integer? || is_real? sql_type.sub(/\((\d+)?\)/, '') else sql_type end end
table_klass()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 142 def table_klass @table_klass ||= begin table_name.classify.constantize rescue StandardError, NameError, LoadError nil end (@table_klass && @table_klass < ActiveRecord::Base) ? @table_klass : nil end
table_name()
click to toggle source
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 138 def table_name @options[:table_name] end
Private Instance Methods
extract_limit(sql_type)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 153 def extract_limit(sql_type) case sql_type when /^smallint/i 2 when /^int/i 4 when /^bigint/i 8 else super end end
simplified_type(field_type)
click to toggle source
Calls superclass method
# File lib/active_record/connection_adapters/nuodb_adapter.rb, line 166 def simplified_type(field_type) case field_type when /bit/i then :boolean when /timestamp/i then :timestamp when /time/i then :time when /date/i then :date when /string/i then :text when /binarystring/i then :binary else super end end