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

Sub models don't update if current value is null #31

Closed
brendonbeebe opened this issue Jul 9, 2013 · 4 comments
Closed

Sub models don't update if current value is null #31

brendonbeebe opened this issue Jul 9, 2013 · 4 comments
Assignees

Comments

@brendonbeebe
Copy link

I have a model "Job" with an id of 1 and a foreign key "type_id"

If the current job.type_id == null and I post the following, nothing happens
{id : 1 , type_id: 1}

If, I however send
{id: 1, type_id: 1, type:{} }

It works perfectly fine. I couldn't figure out what was going on, does anyone have any insight?

@evan108108
Copy link
Owner

Thanks. I am going to look into this...

@evan108108
Copy link
Owner

Okay the latest Master branch has a fix. Thanks again for reporting this bug!

@brendonbeebe
Copy link
Author

A related issue that I would like your feedback on.

If I have the following object
{
"id":"1",
"answer_id":1,
"answer":{"id":"1","quiz_id":"1","question":"What is your best color?","note":null}
}

If I change answer_id but don't change the id in answer object then the record isn't updated but the response from the rest api says "Record Updated." You can see the detailed requests below, I believe the correct functionality would be to have the response state that the record was not updated.

Send:
{
"id":"1",
"answer_id":3,
"answer":{"id":"1","quiz_id":"1","question":"What is your best color?","note":null}
}
Returns success but record was not updated

If how ever I send:
{
"id":"1",
"answer_id":3,
"answer":{"id":"3","quiz_id":"1","question":"What is your best color?","note":null}
}
Returns success and record updates.

@evan108108
Copy link
Owner

Well as you know, you have a mismatch with your BelongsTo. You don't need to include both values, doing so is confusing the ORM. The record has in fact been updated in that the record has been saved, however your BelongsTo is being overwritten so your not seeing it there...

It's a commen problem and one that should be handled. Perhaps you can help me define a better default behavior?

Sent from Mailbox for iPhone

On Fri, Jul 26, 2013 at 11:55 PM, brendonbeebe notifications@github.com
wrote:

A related issue that I would like your feedback on.
If I have the following object
{
"id":"1",
"answer_id":1,
"answer":{"id":"1","quiz_id":"1","question":"What is your best color?","note":null}
}
If I change answer_id but don't change the id in answer object then the record isn't updated but the response from the rest api says "Record Updated." You can see the detailed requests below, I believe the correct functionality would be to have the response state that the record was not updated.
Send:
{
"id":"1",
"answer_id":3,
"answer":{"id":"1","quiz_id":"1","question":"What is your best color?","note":null}
}
Returns success but record was not updated
If how ever I send:
{
"id":"1",
"answer_id":3,
"answer":{"id":"3","quiz_id":"1","question":"What is your best color?","note":null}
}

Returns success and record updates.

Reply to this email directly or view it on GitHub:
#31 (comment)

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

2 participants