Skip to content

Commit

Permalink
Disallow usage of paged_delete in paged_operations plugin on Oracle w…
Browse files Browse the repository at this point in the history
…ith emulated offsets

The approach used does not work correctly in that environment.
  • Loading branch information
jeremyevans committed Sep 26, 2023
1 parent d18e976 commit cc9d8d3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/sequel/plugins/paged_operations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def paged_datasets(opts=OPTS)
# :rows_per_page :: The maximum number of rows affected by each DELETE query
# (unless concurrent modifications are made to the table).
def paged_delete(opts=OPTS)
if db.database_type == :oracle && !supports_fetch_next_rows?
raise Error, "paged_delete is not supported on Oracle when using emulated offsets"
end
pk = _paged_operations_pk(:paged_delete)
rows_deleted = 0
offset_ds = _paged_operations_offset_ds(opts)
Expand Down
8 changes: 8 additions & 0 deletions spec/extensions/paged_operations_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,14 @@
proc{ds.offset(1).paged_datasets{}}.must_raise Sequel::Error
end

it "should raise error paged_delete for Oracle with emulated offsets" do
db = Sequel.mock('oracle')
def db.server_version; 11020002; end
@c.dataset = db[:t]
ds = @c.dataset
proc{ds.offset(1).paged_delete}.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
Expand Down
4 changes: 2 additions & 2 deletions spec/integration/plugin_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3048,7 +3048,7 @@ def set(k, v, ttl) self[k] = v end
end
@model.paged_delete.must_equal 100
@model.count.must_equal 0
end
end unless (DB.database_type == :oracle && !DB.dataset.supports_fetch_next_rows?)

it "Model#paged_update should work on unfiltered dataset" do
expected = 100.times.map{|i| [i+1, i+200]}
Expand Down Expand Up @@ -3089,7 +3089,7 @@ def set(k, v, ttl) self[k] = v end
ds.paged_delete.must_equal 49
ds.count.must_equal 0
@model.count.must_equal 51
end
end unless (DB.database_type == :oracle && !DB.dataset.supports_fetch_next_rows?)

it "Model#paged_update should work on filtered dataset" do
ds = @model.where{id < 50}
Expand Down

0 comments on commit cc9d8d3

Please sign in to comment.