aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2016-01-30 17:09:03 +0900
committerRyuta Kamizono <kamipo@gmail.com>2016-01-30 17:09:03 +0900
commit1a071bae045ca38dc882c5906178b1c59af0cecd (patch)
treed65f5a58055a949cd6a1646bef42d9795085a2a0 /activerecord/lib
parent6162c49e40582bf058a6bb82ccc0cfb8f92332b6 (diff)
downloadrails-1a071bae045ca38dc882c5906178b1c59af0cecd.tar.gz
rails-1a071bae045ca38dc882c5906178b1c59af0cecd.tar.bz2
rails-1a071bae045ca38dc882c5906178b1c59af0cecd.zip
Refactor `OID::Money.precision`
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb6
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb8
2 files changed, 5 insertions, 9 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb
index 2163674019..78039b719c 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/money.rb
@@ -3,12 +3,14 @@ module ActiveRecord
module PostgreSQL
module OID # :nodoc:
class Money < Type::Decimal # :nodoc:
- class_attribute :precision
-
def type
:money
end
+ def precision
+ 19
+ end
+
def scale
2
end
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index 2de6fbfaf0..725173d995 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -213,7 +213,7 @@ module ActiveRecord
@statements = StatementPool.new @connection,
self.class.type_cast_config_to_integer(config.fetch(:statement_limit) { 1000 })
- if postgresql_version < 80200
+ if postgresql_version < 80300
raise "Your version of PostgreSQL (#{postgresql_version}) is too old, please upgrade!"
end
@@ -645,12 +645,6 @@ module ActiveRecord
# connected server's characteristics.
def connect
@connection = PGconn.connect(@connection_parameters)
-
- # Money type has a fixed precision of 10 in PostgreSQL 8.2 and below, and as of
- # PostgreSQL 8.3 it has a fixed precision of 19. PostgreSQLColumn.extract_precision
- # should know about this but can't detect it there, so deal with it here.
- OID::Money.precision = (postgresql_version >= 80300) ? 19 : 10
-
configure_connection
rescue ::PG::Error => error
if error.message.include?("does not exist")