From e35e6171bb27c26b13469ccf188c25bb324e38ab Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 13 Jul 2010 11:56:00 -0700 Subject: reducing range comparisons when converting types to sql --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'activerecord') 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 -- cgit v1.2.3