module Sequel::Postgres::Dataset::ArgumentMapper

PostgreSQL specific argument mapper used for mapping the named argument hash to a array with numbered arguments. Only used with the pg driver.

Protected Instance Methods

map_to_prepared_args(hash) click to toggle source

An array of bound variable values for this query, in the correct order.

# File lib/sequel/adapters/postgres.rb, line 634
def map_to_prepared_args(hash)
  prepared_args.map{|k| hash[k.to_sym]}
end

Private Instance Methods

prepared_arg(k) click to toggle source

PostgreSQL most of the time requires type information for each of arguments to a prepared statement. Handle this by allowing the named argument to have a __* suffix, with the * being the type. In the generated SQL, cast the bound argument to that type to elminate ambiguity (and PostgreSQL from raising an exception).

# File lib/sequel/adapters/postgres.rb, line 645
def prepared_arg(k)
  y, type = k.to_s.split("__")
  if i = prepared_args.index(y)
    i += 1
  else
    prepared_args << y
    i = prepared_args.length
  end
  LiteralString.new("#{prepared_arg_placeholder}#{i}#{"::#{type}" if type}")
end
prepared_arg?(k) click to toggle source

Always assume a prepared argument.

# File lib/sequel/adapters/postgres.rb, line 657
def prepared_arg?(k)
 true
end