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

Record should be destroyed whether it has a range key or not #164

Open
lisad opened this issue Dec 5, 2013 · 0 comments
Open

Record should be destroyed whether it has a range key or not #164

lisad opened this issue Dec 5, 2013 · 0 comments

Comments

@lisad
Copy link
Contributor

lisad commented Dec 5, 2013

I've got some code as follows, in which DeviceToken is a Dynamoid record and phone_number is its hash_key, but it also has a range key :

    DeviceToken.where(phone_number: user.phone_number).each do |device_token|
        device_token.destroy
    end

The 'where' succeeds, but the destroy fails with "a range key value is required for this table"

gems/aws-sdk-1.27.0/lib/aws/dynamo_db/item_collection.rb:244:in `at'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter/aws_sdk.rb:129:in `delete_item'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:146:in `block (3 levels) in <module:Adapter>'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:39:in `benchmark'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:146:in `block (2 levels) in <module:Adapter>'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/adapter.rb:121:in `delete'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:214:in `delete'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/identity_map.rb:84:in `delete'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:203:in `block in destroy'
gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:373:in `_run__1909464996163745819__destroy__callbacks'
gems/ruby-1.9.3-p448/gems/activesupport-4.0.0/lib/active_support/callbacks.rb:80:in `run_callbacks'
gems/ruby-1.9.3-p448/gems/dynamoid-0.7.1/lib/dynamoid/persistence.rb:202:in `destroy'

Since the record has already been looked up by hash_key, destroy should just work

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

No branches or pull requests

1 participant