diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-03 08:55:14 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2010-12-03 08:55:14 -0800 |
commit | dbc1f65244ac0b75f746ea91289f2e36ced435a6 (patch) | |
tree | 93318fc48301e84017e6b3e8bcb3c25cd1106067 /lib | |
parent | e95aba8d1dfbd68b4bc2969f48e353b8de9bf323 (diff) | |
download | rails-dbc1f65244ac0b75f746ea91289f2e36ced435a6.tar.gz rails-dbc1f65244ac0b75f746ea91289f2e36ced435a6.tar.bz2 rails-dbc1f65244ac0b75f746ea91289f2e36ced435a6.zip |
starting the column cache
Diffstat (limited to 'lib')
-rw-r--r-- | lib/arel/visitors/to_sql.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/arel/visitors/to_sql.rb b/lib/arel/visitors/to_sql.rb index 9694ed4cb8..b8a991b965 100644 --- a/lib/arel/visitors/to_sql.rb +++ b/lib/arel/visitors/to_sql.rb @@ -10,6 +10,7 @@ module Arel @last_column = nil @quoted_tables = {} @quoted_columns = {} + @column_cache = {} end def accept object @@ -66,9 +67,17 @@ module Arel o.alias ? " AS #{visit o.alias}" : ''}" end + def column_for relation, name + name = name.to_s + table = relation.name + + columns = @connection.columns(table, "#{table} Columns") + columns.find { |col| col.name.to_s == name } + end + def visit_Arel_Nodes_Values o "VALUES (#{o.expressions.zip(o.columns).map { |value, attr| - quote(value, attr && attr.column) + quote(value, attr && column_for(attr.relation, attr.name)) }.join ', '})" end |