From 1003cb91059347a5865ce5faf62092a48fdc2574 Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 30 Jun 2020 09:24:54 -0700 Subject: [PATCH] Make :ruby eager limit strategy handle case for returns_array? without slice_range correctly --- lib/sequel/model/associations.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/sequel/model/associations.rb b/lib/sequel/model/associations.rb index 38849b29fe..dc4ea773d8 100644 --- a/lib/sequel/model/associations.rb +++ b/lib/sequel/model/associations.rb @@ -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