1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

fix bind values in insert statements

This commit is contained in:
Aaron Patterson 2014-04-09 15:18:43 -07:00
parent f81965509d
commit e33c568f5e
2 changed files with 12 additions and 8 deletions

View file

@ -60,13 +60,13 @@ module Arel
end end
unless o.wheres.empty? unless o.wheres.empty?
collector << "SET " collector << " WHERE "
collector = inject_join o.wheres, collector, ' AND ' collector = inject_join o.wheres, collector, ' AND '
end end
unless o.orders.empty? unless o.orders.empty?
collector << " ORDER BY " collector << " ORDER BY "
collector = inject_join o.wheres, collector, ', ' collector = inject_join o.orders, collector, ', '
end end
if o.limit if o.limit

View file

@ -178,13 +178,17 @@ module Arel
def visit_Arel_Nodes_Values o, collector def visit_Arel_Nodes_Values o, collector
collector << "VALUES (" collector << "VALUES ("
collector << o.expressions.zip(o.columns).map { |value, attr| len = o.expressions.length - 1
o.expressions.zip(o.columns).each_with_index { |(value, attr), i|
if Nodes::SqlLiteral === value if Nodes::SqlLiteral === value
value collector = visit value, collector
else else
quote(value, attr && column_for(attr)) collector << quote(value, attr && column_for(attr)).to_s
end end
}.join(', ') unless i == len
collector << ', '
end
}
collector << ")" collector << ")"
end end