diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-08 21:25:37 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2014-04-08 21:25:37 -0700 |
commit | 59b1d98a5f6268bee661a411f06b285fdb292a47 (patch) | |
tree | 5ac902238e4f78c606642d9e85933f89981f0f9f /lib | |
parent | dc9b23624e5e2a6a5943f8eaef235df59d563805 (diff) | |
download | rails-59b1d98a5f6268bee661a411f06b285fdb292a47.tar.gz rails-59b1d98a5f6268bee661a411f06b285fdb292a47.tar.bz2 rails-59b1d98a5f6268bee661a411f06b285fdb292a47.zip |
fixing insert manager
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 921eeb9b91..2c460ed4ba 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -118,7 +118,7 @@ module Arel collector << "INSERT INTO " collector = visit o.relation, collector if o.columns.any? - collector << "(#{o.columns.map { |x| + collector << " (#{o.columns.map { |x| quote_column_name x.name }.join ', '})" end @@ -171,14 +171,18 @@ module Arel @schema_cache.columns_hash(table) end - def visit_Arel_Nodes_Values o - "VALUES (#{o.expressions.zip(o.columns).map { |value, attr| + def visit_Arel_Nodes_Values o, collector + collector << "VALUES (" + + collector << o.expressions.zip(o.columns).map { |value, attr| if Nodes::SqlLiteral === value - visit value + value else quote(value, attr && column_for(attr)) end - }.join ', '})" + }.join(', ') + + collector << ")" end def visit_Arel_Nodes_SelectStatement o, collector |