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
createinstance and updateinstance in BaseConnection::save are not atomic. #5518
Comments
By batched, you mean the properties being set are not batched together? What do you mean "multiple calls"? Afaik, setting multiple properties to a can.Map and can.DefineMap are batched automatically. Could you share an example of what you are seeing? |
By batched, you mean the properties being set are not batched together? <= yes. What do you mean "multiple calls"?
To fix the example above add batch start/stop. And it would only be printed once. Afaik, setting multiple properties to a can.Map and can.DefineMap are batched automatically. I'm not sure I followed that code correctly, but that would update it 1 by 1 without a batch. I hope I explained myself better / clearly. If not i'll try again with a more complete example. |
We are taking a look at this. Thanks for reporting! |
FYI the patch is short, should I make a pull request ?
|
Sorry about the long delay. Yes, please make a patch! |
I see you added this to 6.6.3 (or earlier) thank you ! |
When createInstance or updateInstance is called in "save: function(instance){}" they are not batched.
As such if you have an observation on an object-instance, you can get multiple calls for each key/member/field/prop.
Fictional example case:
Assume an Object that has to following fields: "GUID, ID, name". To create a new object you only submit "Name" to the server. The server then replies with {"GUID":"0F5581" , "ID":1, name: "Name}. If you now create an observation of that object on GUID and ID, your observation will be trigger twice. If you then required both a valid GUI and ID at that point in time, you will get an error since ID hasn't been updated yet.
Consider adding stop and start batch in these positions.
(I needed to add this for my GUI code to work, the update/creation had to be atomic from the point of the observer.)
The text was updated successfully, but these errors were encountered: