aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2014-05-22 09:12:23 -0700
committerSean Griffin <sean@thoughtbot.com>2014-05-22 09:14:15 -0700
commitecf4ad7cca206e2cf99ca16e57e17648e726877a (patch)
tree0a8e826707d2b8b2441972e35e6c90f35c8ac1bf /activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
parent110d3d0c0bceddd05cab86c0463f0aa71df815cb (diff)
downloadrails-ecf4ad7cca206e2cf99ca16e57e17648e726877a.tar.gz
rails-ecf4ad7cca206e2cf99ca16e57e17648e726877a.tar.bz2
rails-ecf4ad7cca206e2cf99ca16e57e17648e726877a.zip
Allow additional arguments to be used during type map lookups
Determining things like precision and scale in postgresql will require the given blocks to take additional arguments besides the OID. - Adds the ability to handle additional arguments to `TypeMap` - Passes the column type to blocks when looking up PG types
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
index ed3e884455..811c5b5c7a 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -538,12 +538,12 @@ module ActiveRecord
private
- def get_oid_type(oid, fmod, column_name)
+ def get_oid_type(oid, fmod, column_name, sql_type = '')
if !type_map.key?(oid)
initialize_type_map(type_map, [oid])
end
- type_map.fetch(normalize_oid_type(oid, fmod)) {
+ type_map.fetch(normalize_oid_type(oid, fmod), sql_type) {
warn "unknown OID #{oid}: failed to recognize type of '#{column_name}'. It will be treated as String."
Type::Value.new.tap do |cast_type|
type_map.register_type(oid, cast_type)