class Sequel::Postgres::AutoParameterize::QueryString

  1. lib/sequel/extensions/pg_auto_parameterize.rb
Superclass: String

SQL query string that also holds an array of parameters

Attributes

args [R]

The array of parameters used by this query.

Public Instance methods

+(other)

Return a new QueryString with the given string appended to the receiver, and the same arguments.

[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
122 def +(other)
123   v = self.class.new(super)
124   v.instance_variable_set(:@args, @args) if @args
125   v
126 end
add_arg(s)

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

[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
106 def add_arg(s)
107   unless defined?(@args)
108     @args = []
109     @arg_map = {}
110     @arg_map.compare_by_identity
111   end
112 
113   unless pos = @arg_map[s]
114     @args << s
115     pos = @arg_map[s] = @args.length.to_s
116   end
117   self << '$' << pos
118 end
auto_param?()

Whether this query string currently supports automatic parameterization. Automatic parameterization is disabled at certain points during query building where PostgreSQL does not support it.

[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
132 def auto_param?
133   !@skip_auto_param
134 end
freeze()

Freeze the stored arguments when freezing the query string.

[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
150 def freeze
151   if @args
152     @args.freeze
153     @arg_map.freeze
154   end
155   super
156 end
initialize_copy(other)
[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
163 def initialize_copy(other)
164   super
165   if args = other.instance_variable_get(:@args)
166     @args = args.dup
167     @arg_map = other.instance_variable_get(:@arg_map).dup
168   end
169 end
inspect()

Show args when the query string is inspected

[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
159 def inspect
160   @args ? "#{self}; #{@args.inspect}".inspect : super
161 end
skip_auto_param()

Skip automatic parameterization inside the passed block. This is used during query generation to disable automatic parameterization for clauses not supporting it.

[show source]
    # File lib/sequel/extensions/pg_auto_parameterize.rb
139 def skip_auto_param
140   skip_auto_param = @skip_auto_param
141   begin
142     @skip_auto_param = true
143     yield
144   ensure
145     @skip_auto_param = skip_auto_param
146   end
147 end