| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Codecov ReportAll modified and coverable lines are covered by tests ✅ Additional details and impacted files @@ Coverage Diff @@
## master #897 +/- ##
==========================================
+ Coverage 91.56% 91.88% +0.31%
==========================================
Files 75 76 +1
Lines 3700 3856 +156
==========================================
+ Hits 3388 3543 +155
- Misses 312 313 +1 ☔ View full report in Codecov by Sentry.
|
Sorry, something went wrong.
| expect(doc).to be_persisted | ||
| end | ||
| end | ||
| end |
There was a problem hiding this comment.
It's kind of integration tests, so it makes sense to have them, but it will be great to have more thorough specs for each transactional method, like it's done for non-transactional ones:
https://github.com/Dynamoid/dynamoid/blob/master/spec/dynamoid/persistence_spec.rb#L2996-L3037
Such specs would test:
Sorry, something went wrong.
There was a problem hiding this comment.
I'm thinking to not add tests for store_attribute_with_nil_value = true when there is an index. This fails even without transactions. I suppose I could add a test that a ValidationException is thrown in this case. And that test should exist for both transactions and non-transactions.
let(:klass_with_gsi) do
new_class(class_name: 'Ferret') do
field :name
field :age, :number
global_secondary_index hash_key: :name, range_key: :age, projected_attributes: :all, name: 'str_num'
end
end
...
context 'store_attribute_with_nil_value = true', config: { store_attribute_with_nil_value: true } do
it 'can set gsi field to nil' do
doc = klass_with_gsi.new
doc.name = 'abc'
doc.age = 1
doc.save!
doc.age = nil
doc.save! # Aws::DynamoDB::Errors::ValidationException: Invalid attribute value type
end
end
Sorry, something went wrong.
| # changed attributes to persist | ||
| changes = @model.attributes.slice(*@model.changed.map(&:to_sym)) | ||
| changes_dumped = Dynamoid::Dumping.dump_attributes(changes, @model_class.attributes) | ||
| changes_dumped = sanitize_item(changes_dumped) |
There was a problem hiding this comment.
It seems it's more difficult than just skipping nil values. A nullified attribute of an existing item simply will not be updated at all (so old value will be kept unchanged). So correct logic is to remove such attribute at all.
It's done in the following way in non-transactional method #save:
Sorry, something went wrong.
There was a problem hiding this comment.
Indeed. The code I put in there just skips the nils which is not correct. I'll have to do the removing for all these methods like you said.
Sorry, something went wrong.
|
This was bothering me again today. I'll renew my efforts to fix it. |
Sorry, something went wrong.
…sted. Otherwise GSI will fail with a nil range key.
|
@andrykonchin A review of this would be appreciated. Let me know if you see some areas for cleanup. |
Sorry, something went wrong.
|
I'll review this later this week. |
Sorry, something went wrong.
|
@andrykonchin Please review again. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good!
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
TransactionWrite should call sanitize_item so that nils are not persisted. Otherwise GSI will fail with a nil range key.
Closes #885