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 117 117: def literal_append(sql, v) 118: if sql.is_a?(StringWithArray) 119: case v 120: when String 121: case v 122: when LiteralString 123: super 124: when Sequel::SQL::Blob 125: sql.add_arg(v, :bytea) 126: else 127: sql.add_arg(v) 128: end 129: when Bignum 130: sql.add_arg(v, :int8) 131: when Fixnum 132: sql.add_arg(v, :int4) 133: when Float 134: sql.add_arg(v, "double precision""double precision") 135: when BigDecimal 136: sql.add_arg(v, :numeric) 137: when Sequel::SQLTime 138: sql.add_arg(v, :time) 139: when Time, DateTime 140: sql.add_arg(v, :timestamp) 141: when Date 142: sql.add_arg(v, :date) 143: else 144: super 145: end 146: else 147: super 148: end 149: end
Return a clone of the dataset that will not do automatic parameterization.
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 110 110: def no_auto_parameterize 111: clone(:no_auto_parameterize=>true) 112: end
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 151 151: def use_cursor(*) 152: super.no_auto_parameterize 153: end
Disable automatic parameterization for prepared statements, since they will use manual parameterization.
# File lib/sequel/extensions/pg_auto_parameterize.rb, line 159 159: def to_prepared_statement(*a) 160: opts[:no_auto_parameterize] ? super : no_auto_parameterize.to_prepared_statement(*a) 161: end