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