Relationships are not persisted correctly
When trying to store a relationship in Parse I get the following 111 error in the HTTP response: invalid type for key customer, expected relation<Item>, but got "Item"
The payload sent includes a customer key with this object: { __type: "Pointer", className: "Item", "objectId": "D2zBq..." }
That was made through the console, with the following code just for the purpose of testing how things work:
models = controller.model;
models.hypotheses.objectAt(0).set('customer', models.customers.objectAt(0));
models.hypotheses.objectAt(0).save();
I guess the adapter is not correctly naming relationship objects before sending?
@igorsantos07 Any updates on this?
None. I'm focusing on other parts of my project for awhile, hoping the maintainer will take a look at this weird bug.
It would be great if you could share the code for describing your models. Then it would be possible to trace why your column is set to relation<Item> as oppose to pointer<Item>
Hypothesis = DS.Model.extend
customer: DS.belongsTo 'item', async: true
problem: DS.belongsTo 'item', async: true
solution: DS.belongsTo 'item', async: true
risk: DS.belongsTo 'item', async: true
method: DS.attr 'string'
criterion_total: DS.attr 'number'
criterion_valid: DS.attr 'number'
criterion_invalid: DS.attr 'number'
status: DS.attr 'boolean', defaultValue: null
text: DS.attr 'string'
Hey, I think I accidentally found the issue! The problem lies in the type of relations I'm creating at Parse. I've created the tables before persisting them, instead of using a master key. I've stumbled across the Relations doc, and noticed there are actually four ways to build those. I'll take a look at how that behave with the adapter code and report soon :)
I'm fixing my relations in my models and Parse tables. It seems it was a conflict of types.
However, this surfaces an important stuff: we need clear documentation on what Ember relations are what Parse relation types. Also, would be cool to see a clearer error message (example: in case someone uses one-to-many in Ember and Relation [suited for many-to-many] in Parse).