aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2005-11-04 01:49:10 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2005-11-04 01:49:10 +0000
commit427300e08f8ab711a95ecfd66fa6bda82a970aea (patch)
tree31c85c6f334d3bc3d818dc095b5d2fb1414793dc
parentf482bd50186b8cd9150eb370b0d274446aecef2b (diff)
downloadrails-427300e08f8ab711a95ecfd66fa6bda82a970aea.tar.gz
rails-427300e08f8ab711a95ecfd66fa6bda82a970aea.tar.bz2
rails-427300e08f8ab711a95ecfd66fa6bda82a970aea.zip
Quote column names in generated SQL. Closes #2728.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@2866 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG2
-rw-r--r--activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb4
2 files changed, 4 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index 6ca73c2f03..1100c01b35 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Quote column names in generated SQL. #2728 [rtomayko@gmail.com]
+
* Correct the pure-Ruby MySQL 4.1.1 shim's version test. #2718 [Jeremy Kemper]
* Add Model.create! to match existing model.save! method. When save! raises RecordInvalid, you can catch the exception, retrieve the invalid record (invalid_exception.record), and see its errors (invalid_exception.record.errors). [Jeremy Kemper]
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
index b5fe57a0c0..5be344ad06 100644
--- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
+++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -156,12 +156,12 @@ module ActiveRecord
class ColumnDefinition < Struct.new(:base, :name, :type, :limit, :default, :null) #:nodoc:
def to_sql
- column_sql = "#{name} #{type_to_sql(type.to_sym, limit)}"
+ column_sql = "#{base.quote_column_name(name)} #{type_to_sql(type.to_sym, limit)}"
add_column_options!(column_sql, :null => null, :default => default)
column_sql
end
alias to_s :to_sql
-
+
private
def type_to_sql(name, limit)
base.type_to_sql(name, limit) rescue name