From 41f21fafa76e8dc1284650cd24aea2edd770e6b2 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Fri, 3 Feb 2012 17:17:41 -0800 Subject: pgcolumn knows how to typecast binary columns --- .../lib/active_record/connection_adapters/postgresql_adapter.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 5b150f2731..d61ca17391 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -39,6 +39,12 @@ module ActiveRecord super(name, self.class.extract_value_from_default(default), sql_type, null) end + def type_cast(value) + return super unless sql_type == 'bytea' + + PGconn.unescape_bytea(value) if value + end + # :stopdoc: class << self attr_accessor :money_precision -- cgit v1.2.3