diff options
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 361d177967..2e2d50ccf4 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -48,9 +48,12 @@ module ActiveRecord private def extract_limit(sql_type) - return 8 if sql_type =~ /^bigint/i - return 2 if sql_type =~ /^smallint/i - super + case sql_type + when /^integer/i; 4 + when /^bigint/i; 8 + when /^smallint/i; 2 + else super + end end # Extracts the scale from PostgreSQL-specific data types. @@ -795,9 +798,10 @@ module ActiveRecord when 1..2; 'smallint' when 3..4, nil; 'integer' when 5..8; 'bigint' + else raise(ActiveRecordError, "No integer type has byte size #{limit}. Use a numeric with precision 0 instead.") end end - + # Returns a SELECT DISTINCT clause for a given set of columns and a given ORDER BY clause. # # PostgreSQL requires the ORDER BY columns in the select list for distinct queries, and |