Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating an attribute that is a key of a GSI to nil (3.9.0) #679

Closed
zak-raw opened this issue Aug 10, 2023 · 3 comments · Fixed by #681
Closed

Updating an attribute that is a key of a GSI to nil (3.9.0) #679

zak-raw opened this issue Aug 10, 2023 · 3 comments · Fixed by #681

Comments

@zak-raw
Copy link

zak-raw commented Aug 10, 2023

Since 3.9.0, An error Aws::DynamoDB::Errors::ValidationException: Invalid attribute value type is raised when trying to update an attribute that is a key of a GSI to nil via save!, update_attributes!, etc.
This was possible until 3.8.0.

Also, it seems a configuration store_attribute_with_nil_value: false don't work.

Dynamoid.configure do |config|
  config.store_attribute_with_nil_value = false
end

class Hoge
  include Dynamoid::Document

  field :foo_id
  
  global_secondary_index(
    hash_key: :foo_id,
    projected_attributes: :all,
  )
end

hoge = Hoge.new(foo_id: 'bar').save!
hoge.foo_id = nil
hoge.save!
# 'Aws::DynamoDB::Errors::ValidationException: Invalid attribute value type' is raised.
@nbulaj
Copy link

nbulaj commented Aug 11, 2023

Just faced the same issue. Not sure if it's AWS or Dynamoid

image

@andrykonchin
Copy link
Member

andrykonchin commented Aug 20, 2023

Thank you for the bug report. I fixed the issue in #681. Could you please take a look and check whether it fixes your issue?

Not sure that it makes sense to prepare a patch-level release now because there is already one merged PR with refactoring and new feature (#655).

@zak-raw
Copy link
Author

zak-raw commented Aug 21, 2023

@andrykonchin Thank you for your prompt response. 🙇
I checked the diff and I think the issue is resolved.
I will update Gemfile and test our Rails application when 3.9.1 is released.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants