From f726dbe0802395aabf9cc99fe34bc69b375bf344 Mon Sep 17 00:00:00 2001 From: Edward Paget Date: Wed, 14 Jan 2015 12:23:37 -0600 Subject: Delegate to Connection Visitor in WhereSQL Visitor The WhereSQL visitor always uses the generic ToSQL visitor to create the where clause sql statement. This means that it'll miss database specific statements, such as 'ILIKE' in PostgreSQL. Since the `#where_sql` method is mainly used for ActiveRecord error reporting, this discrepancy could be confusing to users. This patch changes the WhereSQL visitor to use the its connection visitor to generate SQL for each statement in the SelectManager's wheres array. Then lets them be joined together with ' AND '. --- lib/arel/visitors/where_sql.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/arel/visitors/where_sql.rb b/lib/arel/visitors/where_sql.rb index afde15a6c5..80797205c9 100644 --- a/lib/arel/visitors/where_sql.rb +++ b/lib/arel/visitors/where_sql.rb @@ -5,7 +5,11 @@ module Arel def visit_Arel_Nodes_SelectCore o, collector collector << "WHERE " - inject_join o.wheres, collector, ' AND ' + wheres = o.wheres.map do |where| + Nodes::SqlLiteral.new(@connection.visitor.accept(where, collector.class.new).value) + end + + inject_join wheres, collector, ' AND ' end end end -- cgit v1.2.3