aboutsummaryrefslogtreecommitdiffstats
path: root/lib/arel/visitors
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2017-04-30 22:19:09 -0400
committerKir Shatrov <shatrov@me.com>2017-05-01 08:21:58 -0400
commit5d6d14cb6be217abc04253da0fe49721d09e9575 (patch)
treeb3ca61f5ff9a083f0b64611788554480d94d36dd /lib/arel/visitors
parent437aa3a4bb8ad4f3f4eba299dbb1112852f9c7ac (diff)
downloadrails-5d6d14cb6be217abc04253da0fe49721d09e9575.tar.gz
rails-5d6d14cb6be217abc04253da0fe49721d09e9575.tar.bz2
rails-5d6d14cb6be217abc04253da0fe49721d09e9575.zip
Support multiple inserts
Diffstat (limited to 'lib/arel/visitors')
-rw-r--r--lib/arel/visitors/to_sql.rb14
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb
index 486c51a183..7143d4e76a 100644
--- a/lib/arel/visitors/to_sql.rb
+++ b/lib/arel/visitors/to_sql.rb
@@ -131,6 +131,7 @@ module Arel
end
if o.values
+ collector << " VALUES"
maybe_visit o.values, collector
elsif o.select
maybe_visit o.select, collector
@@ -166,8 +167,19 @@ module Arel
collector << "FALSE"
end
+ def visit_Arel_Nodes_Tuple o, collector
+ len = o.values.length - 1
+ o.values.each_with_index { |value, i|
+ collector = visit value, collector
+ unless i == len
+ collector << COMMA
+ end
+ }
+ collector
+ end
+
def visit_Arel_Nodes_Values o, collector
- collector << "VALUES ("
+ collector << "("
len = o.expressions.length - 1
o.expressions.each_with_index { |value, i|