Rails部分更新哈希问题

Rails ActiveRecord支持部分更新,并且它在大多数情况下运行良好,但是如果我们有序列化哈希字段AR每次都执行更新,即使没有任何更改。 这里来自rails console的示例:

### Create class and table ### >> class Xx  Object >> ActiveRecord::Base.connection.execute "CREATE TABLE xxes(id serial, params text)" SQL (43.8ms) CREATE TABLE xxes(id serial, params text) => # ### Create record ### >> r = Xx.create(:params => {:a => 1}) SQL (0.9ms) INSERT INTO "xxes" ("params") VALUES ('--- :a: 1 ') RETURNING "id" => #1}> ### Find this record ### >> x = Xx.find(1) Xx Load (2.5ms) SELECT "xxes".* FROM "xxes" WHERE "xxes"."id" = 1 LIMIT 1 => #1}> ### Change nothing and call save ### >> x.save AREL (1.1ms) UPDATE "xxes" SET "params" = '--- :a: 1 ' WHERE "xxes"."id" = 1 => true 

有没有解决方法?