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

Relationships are not persisted correctly #62

Open
igorsantos07 opened this issue Apr 14, 2015 · 6 comments
Open

Relationships are not persisted correctly #62

igorsantos07 opened this issue Apr 14, 2015 · 6 comments

Comments

@igorsantos07
Copy link

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?

@philipheinser
Copy link

@igorsantos07 Any updates on this?

@igorsantos07
Copy link
Author

None. I'm focusing on other parts of my project for awhile, hoping the maintainer will take a look at this weird bug.

@denzo
Copy link

denzo commented Apr 25, 2015

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 as oppose to pointer

@igorsantos07
Copy link
Author

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'

@igorsantos07
Copy link
Author

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 :)

@igorsantos07
Copy link
Author

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).

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

No branches or pull requests

3 participants