From 9d57cd4f9eb462bb1df28a94a35a1435f80b6f44 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Fri, 15 Nov 2024 20:21:57 -0500 Subject: [PATCH] cursor batches --- lib/active_record/batches.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/active_record/batches.rb b/lib/active_record/batches.rb index 7960b6e10d..fb0b13954b 100644 --- a/lib/active_record/batches.rb +++ b/lib/active_record/batches.rb @@ -13,7 +13,9 @@ module ActiveRecord column_names.unshift(primary_key) - relation = relation.reorder(build_batch_orders(order).to_h).limit(batch_limit) + cursor = Array(primary_key) + + relation = relation.reorder(build_batch_orders(cursor, order).to_h).limit(batch_limit) relation.skip_query_cache! batch_relation = relation