Merge pull request #17680 from larskanis/fix_bytea_change_detection

PostgreSQL, Fix change detection caused by superfluous bytea unescaping
This commit is contained in:
Sean Griffin 2014-12-30 13:33:42 -07:00
commit 322750e213
2 changed files with 9 additions and 1 deletions

@ -5,6 +5,7 @@ module OID # :nodoc:
class Bytea < Type::Binary # :nodoc:
def type_cast_from_database(value)
return if value.nil?
return value.to_s if value.is_a?(Type::Binary::Data)
PGconn.unescape_bytea(super)
end
end

@ -688,7 +688,14 @@ def type_cast_for_database(value)
serialize :data
end
klass.create!(data: "foo")
binary = klass.create!(data: "\\\\foo")
assert_not binary.changed?
binary.data = binary.data.dup
assert_not binary.changed?
binary = klass.last
assert_not binary.changed?