Open
Description
I have a use case for which it would be great if I could reuse an index across different models. But it seems it's not possible. Here's how to reproduce:
https://gist.github.com/joarleymoraes/9c8b2b2375d03522b276cc5b35373a5e
The error is:
pynamodb.exceptions.VerboseClientError: An error occurred (ResourceNotFoundException) on request (247af178-87b3-470a-8cd7-d88e2654948a) on table (Model2) when calling the DescribeTable operation: Cannot do operations on a non-existent table
During handling of the above exception, another exception occurred:
pynamodb.exceptions.TableDoesNotExist: Table does not exist: `Cannot do operations on a non-existent table`
It seems that, because Model2
is defined last, it overwrites the index previously assigned to Model1
. So when a query
issued to the index, it looks up the wrong model.
The issue is particularly hard to debug when you create the table Model2
(which is normally is the case), then the query will succeed, but return empty result set.
Not sure if this is by design. Currently, I have to duplicate index definition in order to get it working.