diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-19 09:31:57 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2007-12-19 09:31:57 +0000 |
commit | b4e3b5d41806c20ea29e401ebb613a7db3d44aa8 (patch) | |
tree | 081afc6a9de7da4de176d1e94758e5a51fdebbd8 /activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | |
parent | 7f53d0485f0f6cbec5241dfb25ffafea8b1f49fa (diff) | |
download | rails-b4e3b5d41806c20ea29e401ebb613a7db3d44aa8.tar.gz rails-b4e3b5d41806c20ea29e401ebb613a7db3d44aa8.tar.bz2 rails-b4e3b5d41806c20ea29e401ebb613a7db3d44aa8.zip |
Ruby 1.9 compat: check column type more carefully
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8439 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 8f981438df..8bbadd67e7 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -255,26 +255,27 @@ module ActiveRecord def type_to_sql(type, limit = nil, precision = nil, scale = nil) #:nodoc: if native = native_database_types[type] column_type_sql = native.is_a?(Hash) ? native[:name] : native + if type == :decimal # ignore limit, use precision and scale - precision ||= native[:precision] scale ||= native[:scale] - if precision + + if precision ||= native[:precision] if scale column_type_sql << "(#{precision},#{scale})" else column_type_sql << "(#{precision})" end - else - raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified" if scale + elsif scale + raise ArgumentError, "Error adding decimal column: precision cannot be empty if scale if specified" end - column_type_sql - else - limit ||= native[:limit] - column_type_sql << "(#{limit})" if limit - column_type_sql + + elsif limit ||= native.is_a?(Hash) && native[:limit] + column_type_sql << "(#{limit})" end + + column_type_sql else - column_type_sql = type + type end end |