Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not Functioning Correctly on Partial Updates of Serialized Fields #749

Open
fukata opened this issue May 15, 2024 · 1 comment
Open

Not Functioning Correctly on Partial Updates of Serialized Fields #749

fukata opened this issue May 15, 2024 · 1 comment

Comments

@fukata
Copy link

fukata commented May 15, 2024

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
@andrykonchin
Copy link
Member

andrykonchin commented May 25, 2024

Thank you for reporting the issue. It's definitely a bug and a similar issue with custom types was reported in #666.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants