aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2010-07-13 11:56:00 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2010-07-13 11:56:00 -0700
commite35e6171bb27c26b13469ccf188c25bb324e38ab (patch)
tree59e20d3d9da94f33f1f8fbe731b8e5d58ab9a02b
parent35e304193b8513e1da523a9c1c34bf323e52b9e6 (diff)
downloadrails-e35e6171bb27c26b13469ccf188c25bb324e38ab.tar.gz
rails-e35e6171bb27c26b13469ccf188c25bb324e38ab.tar.bz2
rails-e35e6171bb27c26b13469ccf188c25bb324e38ab.zip
reducing range comparisons when converting types to sql
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index d773be0ca6..e213eae026 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -848,11 +848,12 @@ module ActiveRecord
# Maps logical Rails types to PostgreSQL-specific data types.
def type_to_sql(type, limit = nil, precision = nil, scale = nil)
return super unless type.to_s == 'integer'
+ return 'integer' unless limit
case limit
- when 1..2; 'smallint'
- when 3..4, nil; 'integer'
- when 5..8; 'bigint'
+ when 1, 2; 'smallint'
+ when 3, 4; 'integer'
+ when 5..8; 'bigint'
else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.")
end
end