From a39b2e88e795bc943fb22ec625238c26f1e5a7e7 Mon Sep 17 00:00:00 2001 From: Will Cosgrove Date: Sat, 16 Mar 2024 11:45:16 -0500 Subject: [PATCH] Don't force a CSV collection to render in batches if it has an ordering --- lib/phlex/rails/csv.rb | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/lib/phlex/rails/csv.rb b/lib/phlex/rails/csv.rb index 0b420ce7..14a545e3 100644 --- a/lib/phlex/rails/csv.rb +++ b/lib/phlex/rails/csv.rb @@ -5,12 +5,10 @@ module Rails module CSV module Overrides def each_item(&block) - case collection - when ActiveRecord::Relation - collection.find_each(&block) - else - super - end + return super unless collection.is_a?(ActiveRecord::Relation) + return super unless collection.arel.orders.empty? + + collection.find_each(&block) end end end