Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support for hasMany <-> hasMany relationships #530

Closed
leepfrog opened this Issue · 1 comment

2 participants

@leepfrog

When adding objects to a hasMany relationship where the inverse is a hasMany, an exception is thrown: Invalid Path

Here's the stack. The code fails in normalizeTuple:

(anonymous function)
(anonymous function)
evaluate
InjectedScript._evaluateOn
InjectedScript._evaluateAndWrap
InjectedScript.evaluateOnCallFrame
normalizeTuple ember.js:1822
getPath ember.js:1839
get ember.js:1692
(anonymous function) ember-data.js:4535
DS.OneToManyChange.ensureSameTransaction ember-data.js:4534
DS.OneToManyChange.sync ember-data.js:4611
DS.ManyArray.DS.RecordArray.extend.arrayContentDidChange ember-data.js:424
OrderedSet.forEach ember.js:1410
DS.ManyArray.DS.RecordArray.extend.arrayContentDidChange ember-data.js:423
Ember.wrap.newFunc ember.js:1167
Ember.ArrayProxy.Ember.Object.extend.arrangedContentArrayDidChange ember.js:11195
sendEvent ember.js:3792
Ember.Array.Ember.Mixin.create.arrayContentDidChange ember.js:7942
Ember.Mixin.create.replace ember.js:11606
Ember.ArrayProxy.Ember.Object.extend.replaceContent ember.js:11071
DS.ManyArray.DS.RecordArray.extend.replaceContent ember-data.js:351
Ember.wrap.newFunc ember.js:1167
Ember.ArrayProxy.Ember.Object.extend.replace ember.js:11186
Ember.MutableArray.Ember.Mixin.create.insertAt ember.js:8407
Ember.MutableArray.Ember.Mixin.create.pushObject ember.js:8459
Ember.MutableArray.Ember.Mixin.create.addObject ember.js:8613
(anonymous function)
InjectedScript._evaluateOn
InjectedScript._evaluateAndWrap
InjectedScript.evaluate

After looking at the code, it's because ember-data is expecting the opposite side of a hasMany to be a belongsTo. The workaround is to represent the join model (with belongTo) client-side as well.

@igorT
Owner

This should work now.

@igorT igorT closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.