From 4bf8ffc6516312e68fb0d2b4ac97505f8d0cf192 Mon Sep 17 00:00:00 2001 From: Sean Griffin Date: Thu, 12 Jun 2014 15:13:28 -0600 Subject: Detect in-place changes on mutable AR attributes We have several mutable types on Active Record now. (Serialized, JSON, HStore). We need to be able to detect if these have been modified in place. --- .../lib/active_record/connection_adapters/postgresql/oid/hstore.rb | 6 ++---- .../lib/active_record/connection_adapters/postgresql/oid/json.rb | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) (limited to 'activerecord/lib/active_record/connection_adapters/postgresql/oid') diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb index 88de816d4f..0dd4b65333 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb @@ -3,14 +3,12 @@ module ActiveRecord module PostgreSQL module OID # :nodoc: class Hstore < Type::Value + include Type::Mutable + def type :hstore end - def type_cast_from_user(value) - type_cast_from_database(type_cast_for_database(value)) - end - def type_cast_from_database(value) ConnectionAdapters::PostgreSQLColumn.string_to_hstore(value) end diff --git a/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb b/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb index b4fed1bcab..d1347c7bb5 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql/oid/json.rb @@ -3,14 +3,12 @@ module ActiveRecord module PostgreSQL module OID # :nodoc: class Json < Type::Value + include Type::Mutable + def type :json end - def type_cast_from_user(value) - type_cast_from_database(type_cast_for_database(value)) - end - def type_cast_from_database(value) ConnectionAdapters::PostgreSQLColumn.string_to_json(value) end -- cgit v1.2.3