Replies: 1 comment 2 replies
-
First of all, I am not against introducing a new configuration option if it helps. And compatibility with Rails is quite important. On the other hand as far as I understand, Rails doesn't raise I've checked this behavior in Rails 5.2 and Rails 6.1. Rails raises the exception only if there is no such a column in a table and no public setter in a model (e.g. def _assign_attribute(k, v)
setter = :"#{k}="
if respond_to?(setter)
public_send(setter, v)
else
raise UnknownAttributeError.new(self, k.to_s)
end
end |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I ran into some unexpected behavior, namely the existence of virtual attributes. I was operating under the assumption that, like Rails, if an attribute was not declared (exists in the DB for Rails, declared as a
field
for a Dynamoid::Document), that I'd receive anActiveModel::UnknownAttributeError
. However, this is not the case.Would you be open to making virtual attributes be an opt-out behavior (per model, or global config), so that attempting to initialize an object with an undeclared attribute would act as expected? The one thing I've not checked is if there would be ramifications for load objects from Dynamo which have fields on the actual document which lives in AWS which are not declared in our models.
Looking for thoughts and input.
https://github.com/Dynamoid/dynamoid/blame/master/lib/dynamoid/document.rb#L210
Beta Was this translation helpful? Give feedback.
All reactions