Class Sequel::Amalgalite::SequelTypeMap
In: lib/sequel/adapters/amalgalite.rb
Parent: ::Amalgalite::TypeMaps::DefaultMap

Type conversion map class for Sequel‘s use of Amalgamite

Methods

blob   datetime   decimal   new   result_value_of   time  

Public Class methods

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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 22
22:       def initialize(db)
23:         @db = db
24:       end

Public Instance methods

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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 28
28:       def blob(s)
29:         SQL::Blob.new(s)
30:       end

Return datetime types as instances of Sequel.datetime_class

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 39
39:       def datetime(s)
40:         @db.to_application_timestamp(s)
41:       end

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

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 34
34:       def decimal(s)
35:         BigDecimal.new(s)
36:       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.

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 49
49:       def result_value_of(declared_type, value)
50:         if value.is_a?(::Amalgalite::Blob)
51:           SQL::Blob.new(value.to_s)
52:         elsif value.is_a?(String) && declared_type
53:           (meth = self.class.sql_to_method(declared_type.downcase)) ? send(meth, value) : value
54:         else
55:           super
56:         end
57:       end

[Source]

    # File lib/sequel/adapters/amalgalite.rb, line 43
43:       def time(s)
44:         Sequel.string_to_time(s)
45:       end

[Validate]