class Sequel::Amalgalite::SequelTypeMap
Type conversion map class for Sequel’s use of Amalgamite
Constants
- SQL_TO_METHOD
-
Amalgalite2 support
Public Class Methods
Source
# File lib/sequel/adapters/amalgalite.rb 46 def initialize(db) 47 @db = db 48 end
Store the related database object, in order to be able to correctly handle the database timezone.
Public Instance Methods
Source
# File lib/sequel/adapters/amalgalite.rb 52 def blob(s) 53 SQL::Blob.new(s) 54 end
Return blobs as instances of Sequel::SQL::Blob instead of Amalgamite::Blob
Source
# File lib/sequel/adapters/amalgalite.rb 63 def datetime(s) 64 @db.to_application_timestamp(s) 65 end
Return datetime types as instances of Sequel.datetime_class
Source
# File lib/sequel/adapters/amalgalite.rb 58 def decimal(s) 59 BigDecimal(s) 60 end
Return numeric/decimal types as instances of BigDecimal instead of Float
Source
# File lib/sequel/adapters/amalgalite.rb 21 def result_value_method(type) 22 self.class.sql_to_method(type) 23 end
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
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.
Calls superclass method
Source
# File lib/sequel/adapters/amalgalite.rb 67 def time(s) 68 Sequel.string_to_time(s) 69 end