Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Don't use auto parameterization when using cursors (Fixes #463)

  • Loading branch information...
commit 881c48fb0272154a08c32fed57464dd7f5552c08 1 parent c1f5f98
@jeremyevans authored
View
4 CHANGELOG
@@ -1,5 +1,9 @@
=== HEAD
+* Don't use auto parameterization when using cursors in the pg_auto_parameterize extension (jeremyevans) (#463)
+
+* No longer escape backslashes in strings by default, fixes doubled backslashes on some adapters (jeremyevans)
+
* Escape blackslash-carriage return-line feed in strings on Microsoft SQL Server (mluu, jeremyevans) (#462, #461)
* Remove Array#all_two_pairs? (jeremyevans)
View
4 lib/sequel/extensions/pg_auto_parameterize.rb
@@ -153,6 +153,10 @@ def literal_append(sql, v)
end
end
+ def use_cursor(*)
+ super.no_auto_parameterize
+ end
+
protected
# Disable automatic parameterization for prepared statements,
View
7 spec/extensions/pg_auto_parameterize_spec.rb
@@ -3,8 +3,9 @@
describe "pg_auto_parameterize extension" do
before do
@db = Sequel.connect('mock://postgres', :quote_identifiers=>false)
- @db.extend Sequel::Postgres::AutoParameterize::DatabaseMethods
@db.synchronize{|c| def c.escape_bytea(v) v*2 end}
+ @db.extend_datasets{def use_cursor(*) clone end}
+ @db.extend Sequel::Postgres::AutoParameterize::DatabaseMethods
end
it "should automatically parameterize queries strings, blobs, numerics, dates, and times" do
@@ -57,4 +58,8 @@
it "should show args with string when inspecting SQL " do
@db[:table].filter(:a=>1).sql.inspect.should == '"SELECT * FROM table WHERE (a = $1::int4); [1]"'
end
+
+ it "should not auto parameterize when using cursors" do
+ @db[:table].filter(:a=>1).use_cursor.opts[:no_auto_parameterize].should be_true
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.