Sha256: 6afac99d071cf8567912d26ade6b4e99700eb7dca13c14ce705bffee8de93337

Contents?: true

Size: 985 Bytes

Versions: 1

Compression:

Stored size: 985 Bytes

Contents

require 'upsert/connection/mysql2_client'
require 'upsert/connection/pg_connection'
require 'upsert/connection/sqlite3_database'

class Upsert
  # @private
  class Connection
    attr_reader :parent
    attr_reader :raw_connection

    def initialize(parent, raw_connection)
      @parent = parent
      @raw_connection = raw_connection
    end
    
    def quote_value(v)
      case v
      when NilClass
        NULL_WORD
      when Upsert::Binary
        quote_binary v # must be defined by base
      when String
        quote_string v # must be defined by base
      when TrueClass, FalseClass
        quote_boolean v
      when BigDecimal
        quote_big_decimal v
      when Numeric
        v
      when Symbol
        quote_string v.to_s
      when Time, DateTime
        quote_time v # must be defined by base
      when Date
        quote_string v.strftime(ISO8601_DATE)
      else
        raise "not sure how to quote #{v.class}: #{v.inspect}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
upsert-0.4.0 lib/upsert/connection.rb