diff options
author | Ernie Miller <ernie@erniemiller.org> | 2012-06-14 11:45:51 -0400 |
---|---|---|
committer | Ernie Miller <ernie@erniemiller.org> | 2012-06-14 11:45:51 -0400 |
commit | cbff1bcf385aba876933b2b4569826e9bc46183c (patch) | |
tree | 06c9fb457daaa8a73be891978d7d410894a79eab /lib/arel/visitors | |
parent | 62207faee92c820da9fbc9cc6fe785461c2d826b (diff) | |
download | rails-cbff1bcf385aba876933b2b4569826e9bc46183c.tar.gz rails-cbff1bcf385aba876933b2b4569826e9bc46183c.tar.bz2 rails-cbff1bcf385aba876933b2b4569826e9bc46183c.zip |
Fix in [] to be false, in [] to be true
This is in response to discussion on 62207fa
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index cb8df8329a..a350daa3da 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -370,11 +370,19 @@ key on UpdateManager using UpdateManager#key= end def visit_Arel_Nodes_In o - "#{visit o.left} IN (#{visit o.right})" + if Array === o.right && o.right.empty? + '1=0' + else + "#{visit o.left} IN (#{visit o.right})" + end end def visit_Arel_Nodes_NotIn o - "#{visit o.left} NOT IN (#{visit o.right})" + if Array === o.right && o.right.empty? + '1=1' + else + "#{visit o.left} NOT IN (#{visit o.right})" + end end def visit_Arel_Nodes_And o |