-
Notifications
You must be signed in to change notification settings - Fork 83
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
Duplicate entries in DynamoDB when updating an existing object #162
Comments
Details about my setup: |
I've noticed this too, no duplicates are created if you set the key to something else like: table :key => :user_id Also on the duplicates the id hash remains the same but appended with a changing number .123, is this some kind of versioning - Any ideas on this? |
This is a feature of Dynamoid - see Partitioning 👍 From Readme: With partitioning enabled I suppose .count is not returning the expected result? |
@jasoncox the issue has nothing to do with partitioning. @wagaboy you are getting this behavior because you are saving the field and Dynamoid is automatically filling in the 'id' field with a randomly generated string since you haven't specified what the table key should be (which is why @jasoncox's solution works). However, when you do User.find, it is querying using the index you used and thus is only pulling in the fields from the index and not the saved 'id'. Now you are resaving the object, but the 'id' field is blank and so Dynamoid is generating another random id and resaving the object with that new 'id' resulting in what appear to be two separate objects since User.count queries the table with the primary key not the table with your index. Note that the index table will actually only have one user. |
I have a model (shown below) that gets duplicated (observed from dynamodb console) when I update it.
My sequence of operations, starting with an empty table:
Just calling u.save multiple times on the same object creates multiple entries. Am I missing something-- I'm fairly new to dynamodb and dynamoid. Or is this a bug or a known issue.
My Model
The text was updated successfully, but these errors were encountered: