aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorMatt Aimonetti <mattaimonetti@gmail.com>2013-04-14 16:59:23 -0700
committerMatt Aimonetti <mattaimonetti@gmail.com>2013-04-14 16:59:23 -0700
commit280c5ed1f990c4b29ea214eeaf81d95a8407ce93 (patch)
treea91a28f9de38e2884735337decd5b8197859e40e /activerecord
parent0ddfd75bf67853f14885ff6fbabc65dedb573470 (diff)
downloadrails-280c5ed1f990c4b29ea214eeaf81d95a8407ce93.tar.gz
rails-280c5ed1f990c4b29ea214eeaf81d95a8407ce93.tar.bz2
rails-280c5ed1f990c4b29ea214eeaf81d95a8407ce93.zip
fix for the bytea/binary nil value bug
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/connection_adapters/postgresql/oid.rb1
-rw-r--r--activerecord/test/cases/adapters/postgresql/bytea_test.rb2
2 files changed, 2 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
index 51f377dfd7..14c97dcefc 100644
--- a/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
+++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid.rb
@@ -20,6 +20,7 @@ module ActiveRecord
class Bytea < Type
def type_cast(value)
+ return if value.nil?
PGconn.unescape_bytea value
end
end
diff --git a/activerecord/test/cases/adapters/postgresql/bytea_test.rb b/activerecord/test/cases/adapters/postgresql/bytea_test.rb
index 92f0b5ee04..d7d77f96e2 100644
--- a/activerecord/test/cases/adapters/postgresql/bytea_test.rb
+++ b/activerecord/test/cases/adapters/postgresql/bytea_test.rb
@@ -69,7 +69,7 @@ class PostgresqlByteaTest < ActiveRecord::TestCase
assert_equal(data, record.payload)
end
- def test_write_file
+ def test_write_binary
data = File.read(File.join(File.dirname(__FILE__), '..', '..', '..', 'assets', 'example.log'))
assert(data.size > 1)
record = ByteaDataType.create(payload: data)