aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
diff options
context:
space:
mode:
authorYves Senn <yves.senn@gmail.com>2013-08-07 18:56:49 +0200
committerYves Senn <yves.senn@gmail.com>2014-02-23 13:42:16 +0100
commitd9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62 (patch)
treec6645aed37294bb168362b15c014ec68f68ab118 /activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
parent96759cf6c6a17053abb6a2b7cd87cdbd5a8420ba (diff)
downloadrails-d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62.tar.gz
rails-d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62.tar.bz2
rails-d9314b4c0a8b32f242ed4d394dcc3d45ddfb4c62.zip
Coerce strings when reading attributes.
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid.rb')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid.rb18
1 files changed, 13 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
index 6f9b60b6c4..e7df073627 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
@@ -18,6 +18,14 @@ module ActiveRecord
end
end
+ class Text < Type
+ def type_cast(value)
+ return if value.nil?
+
+ value.to_s
+ end
+ end
+
class Bit < Type
def type_cast(value)
if String === value
@@ -329,7 +337,7 @@ This is not reliable and will be removed in the future.
alias_type 'oid', 'int2'
register_type 'numeric', OID::Decimal.new
- register_type 'text', OID::Identity.new
+ register_type 'text', OID::Text.new
alias_type 'varchar', 'text'
alias_type 'char', 'text'
alias_type 'bpchar', 'text'
@@ -355,13 +363,13 @@ This is not reliable and will be removed in the future.
register_type 'date', OID::Date.new
register_type 'time', OID::Time.new
- register_type 'path', OID::Identity.new
+ register_type 'path', OID::Text.new
register_type 'point', OID::Point.new
- register_type 'polygon', OID::Identity.new
- register_type 'circle', OID::Identity.new
+ register_type 'polygon', OID::Text.new
+ register_type 'circle', OID::Text.new
register_type 'hstore', OID::Hstore.new
register_type 'json', OID::Json.new
- register_type 'ltree', OID::Identity.new
+ register_type 'ltree', OID::Text.new
register_type 'cidr', OID::Cidr.new
alias_type 'inet', 'cidr'