ember-changeset icon indicating copy to clipboard operation
ember-changeset copied to clipboard

Stacklevel too deep during deepMerge (when calling changeset.unexecute())

Open sly7-7 opened this issue 2 years ago • 2 comments

Version

[email protected]

Test Case

I've created a test here: #653

Steps to reproduce

  • Create a changeset from an ember-data model with sync belongsTo
  • Change this belongsTo
  • call changeset.execute()
  • call changeset.unexecute() => exception

Expected Behavior

I was expecting the changeset to have the previous belongsTo model associated.

Actual Behavior

It seems like ember-changeset should work well with Ember-Data, but I think I do somehting wrong, because it crashes during unexecute, when it encounters a belongsTo relation.

Error: Unable to 'mergeDeep' with your data. Are you trying to merge two ember-data objects? Please file an issue with ember-changeset.
    at Proxy.mergeDeep (merge-deep.js:161:1)
    at Proxy.unexecute (validated-changeset.es5.js:409:155)

but I don't do any merge by myself

sly7-7 avatar Jul 08 '22 14:07 sly7-7

@sly7-7 FYI there is related PR #645 which fixes working with Ember Data (there are at least several ways of doing so, that PR suggest one way of doing it).

SergeAstapov avatar Jul 08 '22 15:07 SergeAstapov

@SergeAstapov Hi, thank you for taking time to answer. Unless I'm missing something, my use case is different, as I don't use snapshot/restore, but execute/unexecute. That said, I've tried to run against the PR branch you mentioned, and I have the same "buggy" behavior. When executeing changes to the model, this works fine during deep merge, but when unexecuteing, it tries to deepmerge two ember-data models (even cloning the underlying backburner instance). So I think there is something wrong when the changeset is "saving" the oldContent during execute, which makes unexecute behaves badly.

sly7-7 avatar Jul 11 '22 09:07 sly7-7