From 1c74ad6380135d5acb68384d26c104e243578350 Mon Sep 17 00:00:00 2001 From: Willian van der Velde Date: Tue, 14 May 2024 10:52:39 +0200 Subject: [PATCH] Move Arel enhancement into separate method for some experimental benchmarking In our app, I'd like to last minute do a minor SQL modification experiment. This separate method allows me to override the default behavior slightly more easily. --- lib/arel/middleware/chain.rb | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/arel/middleware/chain.rb b/lib/arel/middleware/chain.rb index e4a13549..28a4047c 100644 --- a/lib/arel/middleware/chain.rb +++ b/lib/arel/middleware/chain.rb @@ -115,6 +115,10 @@ def to_sql(type, &block) private + def enhance_arel(sql, binds) + Arel.enhance(Arel.sql_to_arel(sql, binds: binds)) + end + def execute_with_middleware(sql, binds, execute_sql) check_middleware_recursion(sql) @@ -124,8 +128,7 @@ def execute_with_middleware(sql, binds, execute_sql) cache_accessor: cache_accessor, ) - arel = Arel.sql_to_arel(sql, binds: binds) - enhanced_arel = Arel.enhance(arel) + enhanced_arel = enhance_arel(arel) executor.run(enhanced_arel, updated_context, execute_sql) end