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

changeset.snapshot() does not work with nested keys #24

Closed
SergeAstapov opened this issue Mar 25, 2020 · 1 comment · Fixed by #25
Closed

changeset.snapshot() does not work with nested keys #24

SergeAstapov opened this issue Mar 25, 2020 · 1 comment · Fixed by #25

Comments

@SergeAstapov
Copy link
Contributor

Here is quick reproduction: https://codesandbox.io/s/infallible-meadow-yzt61

Looks like it's been working just fine in ember-changeset@2 because this._changes had format:

{
  "firstName": "Jim",
  "lastName": "B",
  "address.city": "NYC",
  "address.state": "NY"
}

validated-changeset has structure like

{
  "firstName": "Jim",
  "lastName": "B",
  "address": {
    "city": "NYC",
    "state": "NY"
  }
}

so this iteration fails https://github.com/validated-changeset/validated-changeset/blob/master/src/index.ts#L558-L561

Also, changes getter does not work as expected as it returns

[
  {
    "key": "firstName",
    "value": "Jim"
  },
  {
    "key": "lastName",
    "value": "B"
  },
  {
    "key": "address.city",
    "value": "NYC"
  },
  {
    "key": "state",
    "value": "NY"
  }
]
@SergeAstapov
Copy link
Contributor Author

SergeAstapov commented Mar 25, 2020

This should be reopened as #25 fixed only part of the issue.

@snewcomer I tried to look into what's up with snapshot()/restore() - looks like it has the same issue as get changes had and does not play nice with nested keys. I'll submit PR to fix it in the same way as I did in #25.

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

Successfully merging a pull request may close this issue.

1 participant