Skip to content

Not Functioning Correctly on Partial Updates of Serialized Fields #749

Closed
@fukata

Description

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions