Dynamoid icon indicating copy to clipboard operation
Dynamoid copied to clipboard

Indexes work only when the table has id field

Open stefanneculai opened this issue 11 years ago • 2 comments

Index work fine only when the HASH KEY is id.

In my opinion, indexes should not map obj.id but [HASH_KEY, RANGE_VALUE] and use it as an identifier for the row the index is added to. This will make it easy to retrieve the item from the original table this way.

stefanneculai avatar Jun 17 '13 16:06 stefanneculai

So I think the problem here is that on tables with range keys, the 'id' is still only the hash_key. This violates an implied identity:

x = MyTable.create
MyTable.find(x.id) == x ##Broken for tables with range keys

I think the fix is to enhance the id method to return the [hash_key, range_key] tuple, either as a string or as an actual array, though I haven't thought it all the way through.

loganb avatar Jun 19 '13 04:06 loganb

Yes, my fix is a temporary fix, but at least it will partially work when there is no range_key. Changing it to [hash_key, range_key] has a lot of implies in the code and the way data is processed when retrieved from Adapter.

stefanneculai avatar Jun 19 '13 09:06 stefanneculai