Closed nronas closed 4 months ago
Hi! Thank you for submitting this fix. This looks good.
@mullermp done
Sorry, this also needs a changelog entry, you can add something like
Issue - Do not try to hydrate undeclared attributes from storage on `batch_read`.
<newline>
Then it's good to go
@mullermp wasn't sure how the release process goes, will do that asap. Should this be under the Unreleased Changes section on the CHANGELOG.md
?
New version of the gem is out: https://rubygems.org/gems/aws-record/versions/2.13.1
Issue #, if available: N/A
Description of changes:
Hello all and thank you for the great gem. There is an asymmetry around hydrating records on read operations between canonical queries and batch reads. The asymmetry is located around undeclared attributes on the model class.
Example of model with undeclared attribute
On the above model when using canonical queries like
Model.find(ID: '123')
orModel.query(...)
any undeclared attributes are omitted when building the final model instance. So in the above case we will end up with a Model instance that does not have age hydrated onto it.But if we use a Batch Read then the
build_item
method will try to call#=
on Nil.This PR just skips any storage attributes that are not declared on the model class when batch reading
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.