PynamoDB
PynamoDB copied to clipboard
GSIs are not created for polymorphic models
I'm using a single table design and store multiple entitles in one DDB table using discriminator column as specified in the doc. If one of the child entities has it's own GSI and create_table() for this entity is not the first in the list - pynamodb just ignores creation of this GSI, which is hard to localize.
Workaround - move GSI to base model and use base model for table creation.
Expected behavior: Error with clear description or GSI creation
@SZubarev Hi, while I am having similar troubles of not being able to define GSI while using polymorphic models, I am really interested in how you managed to get your workaround work in the meanwhile. I've also tried moving all the models out of polymorphic to base model instead, but I can't seem to set multiple models with the same table_name
.
Thanks in advance!
@mrsakkaro My issue was - I had a Base class and ClassA (with GSI defined) mapped to the same table using polymorphic functionality. I'm using the model for testing using local DynamoDB. I called create_table() for all these classes and the GSI just ignored silently. Then I moved the GSI spec to Base class (table is the same so I can do it easily) and ran create_table() for the Base class first. In this case the GSI was created normally.
It's not an issue for real production work as in this case DDB table and GSIs are just created using CDK script without using create_table() function.