module ArJdbc::SQLite3::Column

@see ActiveRecord::ConnectionAdapters::JdbcColumn

Public Instance Methods

default_value(value) click to toggle source

@override {ActiveRecord::ConnectionAdapters::JdbcColumn#default_value}

# File lib/arjdbc/sqlite3/adapter.rb, line 35
def default_value(value)
  # JDBC returns column default strings with actual single quotes :
  return $1 if value =~ /^'(.*)'$/

  value
end
init_column(name, default, *args) click to toggle source

@override {ActiveRecord::ConnectionAdapters::JdbcColumn#init_column}

Calls superclass method
# File lib/arjdbc/sqlite3/adapter.rb, line 26
def init_column(name, default, *args)
  if default =~ /NULL/
    @default = nil
  else
    super
  end
end
type_cast(value) click to toggle source

@override {ActiveRecord::ConnectionAdapters::Column#type_cast}

Calls superclass method
# File lib/arjdbc/sqlite3/adapter.rb, line 43
def type_cast(value)
  return nil if value.nil?
  case type
  when :string then value
  when :primary_key
    value.respond_to?(:to_i) ? value.to_i : ( value ? 1 : 0 )
  when :float    then value.to_f
  when :decimal  then self.class.value_to_decimal(value)
  when :boolean  then self.class.value_to_boolean(value)
  else super
  end
end

Private Instance Methods

extract_limit(sql_type) click to toggle source

@override {ActiveRecord::ConnectionAdapters::Column#extract_limit}

Calls superclass method
# File lib/arjdbc/sqlite3/adapter.rb, line 77
def extract_limit(sql_type)
  return nil if sql_type =~ /^(real)\(\d+/i
  super
end
extract_precision(sql_type) click to toggle source
Calls superclass method
# File lib/arjdbc/sqlite3/adapter.rb, line 82
def extract_precision(sql_type)
  case sql_type
    when /^(real)\((\d+)(,\d+)?\)/i then $2.to_i
    else super
  end
end
extract_scale(sql_type) click to toggle source
Calls superclass method
# File lib/arjdbc/sqlite3/adapter.rb, line 89
def extract_scale(sql_type)
  case sql_type
    when /^(real)\((\d+)\)/i then 0
    when /^(real)\((\d+)(,(\d+))\)/i then $4.to_i
    else super
  end
end
simplified_type(field_type) click to toggle source

@override {ActiveRecord::ConnectionAdapters::Column#simplified_type}

Calls superclass method
# File lib/arjdbc/sqlite3/adapter.rb, line 59
def simplified_type(field_type)
  case field_type
  when /boolean/i       then :boolean
  when /text/i          then :text
  when /varchar/i       then :string
  when /int/i           then :integer
  when /float/i         then :float
  when /real|decimal/i  then
    extract_scale(field_type) == 0 ? :integer : :decimal
  when /datetime/i      then :datetime
  when /date/i          then :date
  when /time/i          then :time
  when /blob/i          then :binary
  else super
  end
end