aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvanderhoorn <vanderhoorn@users.noreply.github.com>2014-02-05 13:21:19 +0100
committervanderhoorn <vanderhoorn@users.noreply.github.com>2014-02-05 13:21:19 +0100
commitf3938cd77a2e2602a919c3ce4189f29f056dc68c (patch)
treec8b3ffd14db0e680d5b102d56fd3600435faf0f0
parentf0ba9e4e56cf4dfa266147fad7e8f58ca577d614 (diff)
downloadrails-f3938cd77a2e2602a919c3ce4189f29f056dc68c.tar.gz
rails-f3938cd77a2e2602a919c3ce4189f29f056dc68c.tar.bz2
rails-f3938cd77a2e2602a919c3ce4189f29f056dc68c.zip
PostgreSQL bugfix for invalid SQL in subqueries
In commit 68a95542e1a7a79d9777223fbffd2b982fed0268 the last_column feature of ToSql was removed. The visit_Arel_Nodes_Matches and visit_Arel_Nodes_DoesNotMatch methods are overwritten in the PostgreSQL class, but were not updated appropriately. This commit fixes the issue accordingly. This bug affects at least all update_all statements in Rails 4.0.2 that have subqueries with ILIKE statements on PostgreSQL. The bug is present in Arel 4.0.1 and later, so it probably affects most Rails 4.0.2 projects. It would be highly appreciated if Arel 4 could get a point release as well. Thanks for your continued work.
-rw-r--r--lib/arel/visitors/postgresql.rb2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/arel/visitors/postgresql.rb b/lib/arel/visitors/postgresql.rb
index 080e402e3b..7520a1ccc7 100644
--- a/lib/arel/visitors/postgresql.rb
+++ b/lib/arel/visitors/postgresql.rb
@@ -4,10 +4,12 @@ module Arel
private
def visit_Arel_Nodes_Matches o, a
+ a = o.left if Arel::Attributes::Attribute === o.left
"#{visit o.left, a} ILIKE #{visit o.right, a}"
end
def visit_Arel_Nodes_DoesNotMatch o, a
+ a = o.left if Arel::Attributes::Attribute === o.left
"#{visit o.left, a} NOT ILIKE #{visit o.right, a}"
end