dynamoid icon indicating copy to clipboard operation
dynamoid copied to clipboard

Not Functioning Correctly on Partial Updates of Serialized Fields

Open fukata opened this issue 9 months ago • 1 comments

It seems that changing the value of the serialized field called "options" does not set "changed?" to true. It works correctly when the entire "options" field is modified.

Is this the expected behavior?

Reproduction

Dynamoid: v3.9.0 Ruby: 3.3.0

Sample Test

    context 'serialized field' do
      let(:model) do
        new_class do
          field :options, :serialized
        end
      end

      it 'returns true if serialized field has unsaved changes' do
        obj = model.new(options: {})
        expect(obj.changed?).to eq true

        obj = model.create(options: {})
        obj.options['name'] = 'Alex'
        expect(obj.changed?).to eq true
      end

      it 'returns true if serialized field has unsaved changes other object ' do
        obj = model.new(options: {})
        expect(obj.changed?).to eq true

        obj = model.create(options: {})
        obj.options = {'name' => 'Alex'}
        expect(obj.changed?).to eq true
      end
    end

fukata avatar May 15 '24 14:05 fukata