diff --git a/lib/sequel/plugins/paged_operations.rb b/lib/sequel/plugins/paged_operations.rb index eb8eeaad3..5e1368d65 100644 --- a/lib/sequel/plugins/paged_operations.rb +++ b/lib/sequel/plugins/paged_operations.rb @@ -150,6 +150,9 @@ def paged_update(values, opts=OPTS) # and return the primary key to operate on as a Sequel::Identifier. def _paged_operations_pk(meth) raise Error, "cannot use #{meth} if dataset has a limit or offset" if @opts[:limit] || @opts[:offset] + if db.database_type == :db2 && db.offset_strategy == :emulate + raise Error, "the paged_operations plugin is not supported on DB2 when using emulated offsets, set the :offset_strategy Database option to 'limit_offset' or 'offset_fetch'" + end case pk = model.primary_key when Symbol diff --git a/spec/extensions/paged_operations_spec.rb b/spec/extensions/paged_operations_spec.rb index dc6da4f03..2290cffad 100644 --- a/spec/extensions/paged_operations_spec.rb +++ b/spec/extensions/paged_operations_spec.rb @@ -181,6 +181,14 @@ proc{@ds.limit(1).paged_datasets{}}.must_raise Sequel::Error end + it "should raise error for DB2 with emulated offsets" do + @c.dataset = Sequel.mock('db2')[:t] + ds = @c.dataset + proc{ds.offset(1).paged_delete}.must_raise Sequel::Error + proc{ds.offset(1).paged_update(:x=>1)}.must_raise Sequel::Error + proc{ds.offset(1).paged_datasets{}}.must_raise Sequel::Error + end + it "should raise error for dataset with offset" do proc{@ds.offset(1).paged_delete}.must_raise Sequel::Error proc{@ds.offset(1).paged_update(:x=>1)}.must_raise Sequel::Error diff --git a/spec/integration/plugin_test.rb b/spec/integration/plugin_test.rb index 030c8f3ef..93e324cdf 100644 --- a/spec/integration/plugin_test.rb +++ b/spec/integration/plugin_test.rb @@ -3123,4 +3123,4 @@ def set(k, v, ttl) self[k] = v end ds.paged_datasets{|ds| counts << ds.count} counts.must_equal [49] end -end +end unless DB.database_type == :db2 && DB.offset_strategy == :emulate