diff --git a/lib/arel/middleware/chain.rb b/lib/arel/middleware/chain.rb index e4a13549..bc737571 100644 --- a/lib/arel/middleware/chain.rb +++ b/lib/arel/middleware/chain.rb @@ -115,6 +115,11 @@ def to_sql(type, &block) private + def enhance_arel(sql, binds) + arel = Arel.sql_to_arel(sql, binds: binds) + Arel.enhance(arel) + end + def execute_with_middleware(sql, binds, execute_sql) check_middleware_recursion(sql) @@ -124,8 +129,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 sql, binds executor.run(enhanced_arel, updated_context, execute_sql) end