Repository navigation
Conversation
These methods are useless sugar and are quite dangerous. They implement last-write-wins while having names that suggest atomicity and safety. The AR convention seems to prefer that `UPDATE` queries be made via class methods - these methods are already available in `CounterCache`. Reintroducing these methods is a tricky proposition, because doing it right means adding a read immediately after the update to update the in-memory value; this requires a transaction and some state tracking to ensure that other dirty attributes are not discarded.
Member
|
👍 |
This was referenced Sep 26, 2014
Member
|
Yeah, handing out this API without a disclaimer or guidance is asking for incorrect usage and app data inconsistency. To use this as-is, you need to take an exclusive lock on the row when it's read. Removing the API won't remove apps' need for it. Better for apps to rely on something we can improve (and document) rather than independently building N buggy implementations with the same issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
These methods are useless sugar and are quite dangerous. They implement
last-write-wins while having names that suggest atomicity and safety.
The AR convention seems to prefer that
UPDATEqueries be made viaclass methods - these methods are already available in
CounterCache.Reintroducing these methods is a tricky proposition, because doing it
right means adding a read immediately after the update to update the
in-memory value; this requires a transaction and some state tracking to
ensure that other dirty attributes are not discarded.
This might be appropriate for 5.0.
cc @bogdan