Type conversion map class for Sequel’s use of Amalgamite
Store the related database object, in order to be able to correctly handle the database timezone.
# File lib/sequel/adapters/amalgalite.rb, line 22 def initialize(db) @db = db end
Return blobs as instances of Sequel::SQL::Blob instead of Amalgamite::Blob
# File lib/sequel/adapters/amalgalite.rb, line 28 def blob(s) SQL::Blob.new(s) end
Return datetime types as instances of Sequel.datetime_class
# File lib/sequel/adapters/amalgalite.rb, line 39 def datetime(s) @db.to_application_timestamp(s) end
Return numeric/decimal types as instances of BigDecimal instead of Float
# File lib/sequel/adapters/amalgalite.rb, line 34 def decimal(s) BigDecimal.new(s) 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.
# File lib/sequel/adapters/amalgalite.rb, line 49 def result_value_of(declared_type, value) if value.is_a?(::Amalgalite::Blob) SQL::Blob.new(value.to_s) elsif value.is_a?(String) && declared_type (meth = self.class.sql_to_method(declared_type.downcase)) ? send(meth, value) : value else super end end
# File lib/sequel/adapters/amalgalite.rb, line 43 def time(s) Sequel.string_to_time(s) end