Permalink
Browse files

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

  • Loading branch information...
1 parent c1f5f98 commit 881c48fb0272154a08c32fed57464dd7f5552c08 @jeremyevans committed Apr 3, 2012
Showing with 14 additions and 1 deletion.
  1. +4 −0 CHANGELOG
  2. +4 −0 lib/sequel/extensions/pg_auto_parameterize.rb
  3. +6 −1 spec/extensions/pg_auto_parameterize_spec.rb
View
@@ -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)
@@ -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,
@@ -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

0 comments on commit 881c48f

Please sign in to comment.