diff --git a/lib/sequel/extensions/pg_auto_parameterize.rb b/lib/sequel/extensions/pg_auto_parameterize.rb index f09c767ee..b48361b55 100644 --- a/lib/sequel/extensions/pg_auto_parameterize.rb +++ b/lib/sequel/extensions/pg_auto_parameterize.rb @@ -394,7 +394,7 @@ def auto_param?(sql) # there can be more than one parameter per column, so this doesn't prevent going # over the limit, though it does make it less likely. def default_import_slice - 40 + @opts[:no_auto_parameterize] ? super : 40 end # Handle parameterization of multi_insert_sql diff --git a/spec/extensions/pg_auto_parameterize_spec.rb b/spec/extensions/pg_auto_parameterize_spec.rb index b01175485..2864860da 100644 --- a/spec/extensions/pg_auto_parameterize_spec.rb +++ b/spec/extensions/pg_auto_parameterize_spec.rb @@ -63,6 +63,14 @@ def copy_table_sql(ds, *) "COPY TABLE #{ds.is_a?(Sequel::Dataset) ? ds.sql : ds} sqls[1].must_equal 'INSERT INTO "table" ("a") VALUES ' + args[0...40].map{|i| "($#{i}::int4)"}.join(', ') + " -- args: #{args[40...80].inspect}" end + it "should not split inserts of multiple rows to 40 at a time with no_auto_parameterize" do + args = (1...81).to_a + @db[:table].no_auto_parameterize.import([:a], args) + sqls = @db.sqls + sqls.size.must_equal 1 + sqls[0].must_equal 'INSERT INTO "table" ("a") VALUES ' + args.map{|i| "(#{i})"}.join(', ') + end + it "should automatically parameterize queries strings, blobs, numerics, dates, and times" do ds = @db[:table] pr = proc do |sql, *args|