class Sequel::Amalgalite::SequelTypeMap

  1. lib/sequel/adapters/amalgalite.rb
Superclass: Amalgalite::TypeMaps::DefaultMap

Type conversion map class for Sequel’s use of Amalgamite

Methods

Public Class

  1. new

Public Instance

  1. blob
  2. datetime
  3. decimal
  4. result_value_method
  5. result_value_of
  6. time

Constants

SQL_TO_METHOD = superclass::SQL_TO_METHOD.merge( 'datetime' => :datetime, 'timestamp' => :datetime, 'time' => :time, 'float' => :float, 'double' => :float, 'real' => :float, 'double precision' => :float, 'decimal' => :decimal, 'numeric' => :decimal, 'money' => :decimal )  

Amalgalite 2 support

Public Class methods

new(db)

Store the related database object, in order to be able to correctly handle the database timezone.

[show source]
   # File lib/sequel/adapters/amalgalite.rb
46 def initialize(db)
47   @db = db
48 end

Public Instance methods

blob(s)

Return blobs as instances of Sequel::SQL::Blob instead of Amalgamite::Blob

[show source]
   # File lib/sequel/adapters/amalgalite.rb
52 def blob(s)
53   SQL::Blob.new(s)
54 end
datetime(s)

Return datetime types as instances of Sequel.datetime_class

[show source]
   # File lib/sequel/adapters/amalgalite.rb
63 def datetime(s)
64   @db.to_application_timestamp(s)
65 end
decimal(s)

Return numeric/decimal types as instances of BigDecimal instead of Float

[show source]
   # File lib/sequel/adapters/amalgalite.rb
58 def decimal(s)
59   BigDecimal(s)
60 end
result_value_method(type)
[show source]
   # File lib/sequel/adapters/amalgalite.rb
21 def result_value_method(type)
22   self.class.sql_to_method(type)
23 end
result_value_of(declared_type, value)

Don’t raise an error if the value is a string and the declared type doesn’t match a known type, just return the value.

[show source]
   # File lib/sequel/adapters/amalgalite.rb
73 def result_value_of(declared_type, value)
74   if value.is_a?(::Amalgalite::Blob)
75     SQL::Blob.new(value.to_s)
76   elsif value.is_a?(String) && declared_type
77     (meth = result_value_method(declared_type.downcase)) ? public_send(meth, value) : value
78   else
79     super
80   end
81 end
time(s)
[show source]
   # File lib/sequel/adapters/amalgalite.rb
67 def time(s)
68   Sequel.string_to_time(s)
69 end