diff options
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 974f9f5341..112466548d 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -202,8 +202,9 @@ module Arel def visit_Arel_Nodes_NotIn o right = o.right - right = right.empty? ? 'NULL' : right.map { |x| visit x }.join(', ') - "#{visit o.left} NOT IN (#{right})" + "#{visit o.left} NOT IN (#{ + right.empty? ? 'NULL' : right.map { |x| visit x }.join(', ') + })" end def visit_Arel_Nodes_And o |