Skip to content

Commit

Permalink
Make :ruby eager limit strategy handle case for returns_array? withou…
Browse files Browse the repository at this point in the history
…t slice_range correctly
  • Loading branch information
jeremyevans committed Jun 30, 2020
1 parent f94ecac commit 1003cb9
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/sequel/model/associations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,11 @@ def apply_window_function_eager_limit_strategy(ds, limit_and_offset=limit_and_of
# range to return the object(s) at the correct offset/limit.
def apply_ruby_eager_limit_strategy(rows, limit_and_offset = limit_and_offset())
name = self[:name]
return unless range = slice_range(limit_and_offset)
if returns_array?
range = slice_range(limit_and_offset)
rows.each{|o| o.associations[name] = o.associations[name][range] || []}
elsif sr = slice_range(limit_and_offset)
offset = sr.begin
else
offset = range.begin
rows.each{|o| o.associations[name] = o.associations[name][offset]}
end
end
Expand Down

0 comments on commit 1003cb9

Please sign in to comment.