| Module | Sequel::Postgres::AutoParameterize::DatasetMethods |
| In: |
lib/sequel/extensions/pg_auto_parameterize.rb
|
For strings, numeric arguments, and date/time arguments, add them as parameters to the query instead of literalizing them into the SQL.
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 127
127: def literal_append(sql, v)
128: if sql.is_a?(StringWithArray)
129: case v
130: when String
131: case v
132: when LiteralString
133: super
134: when Sequel::SQL::Blob
135: sql.add_arg(v, :bytea)
136: else
137: sql.add_arg(v)
138: end
139: when Bignum
140: sql.add_arg(v, :int8)
141: when Fixnum
142: sql.add_arg(v, :int4)
143: when Float
144: sql.add_arg(v, "double precision""double precision")
145: when BigDecimal
146: sql.add_arg(v, :numeric)
147: when Sequel::SQLTime
148: sql.add_arg(v, :time)
149: when Time, DateTime
150: sql.add_arg(v, :timestamp)
151: when Date
152: sql.add_arg(v, :date)
153: else
154: super
155: end
156: else
157: super
158: end
159: end
Return a clone of the dataset that will not do automatic parameterization.
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 120
120: def no_auto_parameterize
121: clone(:no_auto_parameterize=>true)
122: end
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 161
161: def use_cursor(*)
162: super.no_auto_parameterize
163: end
Disable automatic parameterization for prepared statements, since they will use manual parameterization.
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 169
169: def to_prepared_statement(*a)
170: opts[:no_auto_parameterize] ? super : no_auto_parameterize.to_prepared_statement(*a)
171: end