aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors/where_sql.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2015-12-17 12:54:27 -0700
committerSean Griffin <sean@seantheprogrammer.com>2015-12-17 12:54:46 -0700
commitcd395b9419ac3a860ee78cf9706af1bf7d86fe92 (patch)
tree55e2b126325cbfea1348bcd856610ce8d9f8bcc0 /lib/arel/visitors/where_sql.rb
parentf726dbe0802395aabf9cc99fe34bc69b375bf344 (diff)
downloadrails-cd395b9419ac3a860ee78cf9706af1bf7d86fe92.tar.gz
rails-cd395b9419ac3a860ee78cf9706af1bf7d86fe92.tar.bz2
rails-cd395b9419ac3a860ee78cf9706af1bf7d86fe92.zip
Inject the visitor rather than relying on other objects internals
This is ultimately messy no matter what, and increases the coupling to the database backend, but we can at least contain it somewhat into an object that's already coupled.
Diffstat (limited to 'lib/arel/visitors/where_sql.rb')
-rw-r--r--lib/arel/visitors/where_sql.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/arel/visitors/where_sql.rb b/lib/arel/visitors/where_sql.rb
index 80797205c9..41972d5836 100644
--- a/lib/arel/visitors/where_sql.rb
+++ b/lib/arel/visitors/where_sql.rb
@@ -1,12 +1,17 @@
module Arel
module Visitors
class WhereSql < Arel::Visitors::ToSql
+ def initialize(inner_visitor, *args, &block)
+ @inner_visitor = inner_visitor
+ super(*args, &block)
+ end
+
private
def visit_Arel_Nodes_SelectCore o, collector
collector << "WHERE "
wheres = o.wheres.map do |where|
- Nodes::SqlLiteral.new(@connection.visitor.accept(where, collector.class.new).value)
+ Nodes::SqlLiteral.new(@inner_visitor.accept(where, collector.class.new).value)
end
inject_join wheres, collector, ' AND '