Record Instance Update
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Start at ItemOperations#_perform_save and read issue #58 for the GSI behavior that update currently misses. Compare the existing save and update paths, then define upsert's expected handling of dirty columns, record creation, and the conditional-write race; it is done when the requested MyRecord example updates the dynamic GSI correctly.
Written by the indexing model from the issue text.
Description
Right now save (or save!) encapsulates the selection between a put and an update, with the ability to force put. I recently wanted a "find or create" method, and naively did:
record = MyRecord.find(key: 123)
record ||= MyRecord.new(key: 123)
...
record.save! #=> Conditional write exception
I end up receiving the conditional write exception because some other process is trying to create the same record.
To fix this, I moved to using an update:
MyRecord.update(key: 123, value: 'some new data')
However, we have a GSI which is dynamically generated from the values which update never takes into account (see issue #58). Thus, the preferred solution would be:
MyRecord.new(key: 123, value: 'some new data').upsert!
To achieve this I copied the else statement from ItemOperations#_perform_save which builds an update request for dirty columns and creates the record if it does not already exist; hence upsert.
- Dominant language
- Ruby
- Stars
- 318
- Forks
- 44
- PR merge metrics
- No merged PRs in 30d
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from aws/aws-record-ruby
-
BuildableSearch#complete!.to_a auto-paginates silently and Limit is per-page (companion to #153) Openfeature-request
Difficulty 5/5 Over a week Newbie friendliness 25/100
aws/aws-record-ruby#157 · 2 comments ·
-
feature-request
Difficulty 5/5 Over a week Newbie friendliness 38/100
aws/aws-record-ruby#155 · 1 comment ·
-
feature-request needs-triage
Difficulty 4/5 3-5 days Newbie friendliness 48/100
aws/aws-record-ruby#153 · 2 comments ·
-
feature-request
Difficulty 5/5 Over a week Newbie friendliness 35/100
aws/aws-record-ruby#152 · 3 comments ·
-
feature-request
Difficulty 4/5 3-5 days Newbie friendliness 35/100
aws/aws-record-ruby#147 · 1 comment ·
All issues in aws/aws-record-ruby
Similar issues
-
user-reported
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Kong/developer.konghq.com#7316 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
TheOdinProject/curriculum#31408 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
notch8/utk_knapsack#148 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 78/100
Homebrew/homebrew-cask#288729 · 1 comment ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100