Method: Sequel::Postgres::AutoParameterize::QueryString#add_arg

Defined in:
lib/sequel/extensions/pg_auto_parameterize.rb

#add_arg(s) ⇒ Object

Add a new parameter to this query, which adds the parameter to the array of parameters, and an SQL placeholder to the query itself.



106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/sequel/extensions/pg_auto_parameterize.rb', line 106

def add_arg(s)
  unless defined?(@args)
    @args = []
    @arg_map = {}
    @arg_map.compare_by_identity
  end

  unless pos = @arg_map[s]
    @args << s
    pos = @arg_map[s] = @args.length.to_s
  end
  self << '$' << pos
end