Skip to content

The behavior change of insertOrUpdate is as expected? #516

@tofu2323

Description

@tofu2323

Hello.
I updated Vuex ORM to latest 0.34.1 from 0.33.0.
However I realized there is a breaking changes for me.

The value of object passed as argument of insertOrUpdate will be changed inside the method.
Here are an example.
https://codesandbox.io/s/vuex-orm-template-2l8nq

class Profile extends Model {
  static entity = "profiles";

  static fields() {
    return {
      id: this.attr(null),
      user_id: this.attr(null),
      age: this.attr("")
    };
  }
}

class User extends Model {
  static entity = "users";

  static fields() {
    return {
      id: this.attr(null),
      name: this.attr(""),
      profile: this.hasOne(Profile, "user_id")
    };
  }
}
    const user = {
      id: 1,
      name: "Taro",
      profile: {
        id: 2,
        user_id: 1,
        age: 25
      }
    };
    this.before = user.profile;  //  { "id": 2, "user_id": 1, "age": 25, "$id": "2" }
    User.insertOrUpdate({ data: user });
    this.after = user.profile;  //  2

When I use v0.33.0 the value of this.before and this.after are same, but v0.34.x it are different.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingresolvedIssue have been resolved but not yet released

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions