Skip to content

Cannot update value inside JSON #12960

Closed
Closed

Description

@xtance

Issue Description

Updating JSON field doesn't update

What are you doing?

I have a field with JSON type, which is a json array containing other arrays. After modifying values, they cannot be updated in database.

For example, I have:

[[1]] (an array inside array)

And I'm trying push something:

instance.arr[0].push(1); // [[1,1]]
instance.save();
// or:
instance.update({arr: instance.arr});

Now inside instance I have changed array and nothing changed inside db. Not even a query is sent. :(

What do you expect to happen?

I wanted it to get updated in database aswell

What is actually happening?

For some reason it ignores that field completely. I would like to have a force update option.
(As of today I have to do a deep copy of array to save it.)

Additional context

Add any other context or screenshots about the feature request here.

Environment

  • Sequelize version: [email protected]
  • Node.js version: v14.15.3
  • Operating System: Windows 10

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using MariaDB, with connector library version (IDK sorry) and database version 10.3.25-MariaDB-0+deb10u1

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

Activity

  1. xtance commented on Jan 19, 2021

    @xtance
    Author

    Sorry, people on stackoverflow reminded me about instance.changed('arr', true); option, please delete this issue as it's not really an issue now

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