Skip to content

Commit

Permalink
Move Arel enhancement into separate method for some experimental benc…
Browse files Browse the repository at this point in the history
…hmarking

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.
  • Loading branch information
Willianvdv authored May 14, 2024
1 parent 6d79b13 commit 1c74ad6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/arel/middleware/chain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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
Expand Down

0 comments on commit 1c74ad6

Please sign in to comment.