Sha256: f71e6c304da8bfdfc861201882ca1e522aaccfa4ca30433f736394b4453224ef

Contents?: true

Size: 850 Bytes

Versions: 2

Compression:

Stored size: 850 Bytes

Contents

class Upsert
  class Cell
    # @private
    class SQLite3_Database < Cell
      attr_reader :name
      attr_reader :value
      attr_reader :quoted_name

      def initialize(connection, name, value)
        @name = name
        @value = value
        @quoted_name = connection.quote_ident name
      end

      def bind_value
        return @bind_value if defined?(@bind_value)
        @bind_value = case value
        when Upsert::Binary
          SQLite3::Blob.new value.value
        when BigDecimal
          value.to_s('F')
        when TrueClass
          't'
        when FalseClass
          'f'
        when Time, DateTime
          [value.strftime(ISO8601_DATETIME), sprintf(USEC_SPRINTF, value.usec)].join('.')
        when Date
          value.strftime ISO8601_DATE
        else
          value
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
upsert-1.0.2 lib/upsert/cell/SQLite3_Database.rb
upsert-0.5.0 lib/upsert/cell/sqlite3_database.rb