Hi all,
I’m struggling with the case where a record that’s in a transaction becomes invalid due to client-side validations (ember-validations in this case). It appears that it’s automatically removed from the transaction, and when it becomes valid again it is not re-added.
I can’t think of an elegant way of handling this. Does anyone have a good solution?
Thanks in advance
I found the (bug?) and logged it in ember-data.
https://github.com/emberjs/data/issues/1016
I think the name “transaction” is misleading and gives people the wrong mental model of what’s happening.
Probably a better way to think about DS.Transaction
is that it’s a group of records that you would like to commit together. Unfortunately, due to the semantics of HTTP, we have no way of guaranteeing atomicity in the commit—it’s completely possible that one record completes successfully and then another record receives a 422
response code and gets marked as invalid.
I think the correct behavior here is that—no matter what the response from the server is—the record gets moved from its transaction and back into the default transaction once any acknowledgment from the adapter is received.
Hi Tom,
Thanks for your help. In this case, it’s a client side validation that’s causing the record to entire the invalid state, so I don’t think it makes sense to pop it out of the transaction.
The Model Lifecycle Guide says that the isValid state indicates that “No client-side validations have failed and the adapter did not report any server-side validation failures.”
With both client and server side failures being indicated the same, I’m not sure how to handle this elegantly.