Open
Description
class ItemEmailIdIndex(GlobalSecondaryIndex):
class Meta:
index_name = "itemEmailIdIndex"
projection = KeysOnlyProjection()
email_id = UnicodeAttribute(hash_key=True)
sk = UnicodeAttribute(range_key=True)
class Item(Model, discriminator="Item"):
class Meta:
table_name = f"items-{STAGE}"
region = os.environ.get("AWS_REGION")
pk = UnicodeAttribute(hash_key=True)
sk = UnicodeAttribute(range_key=True)
itemEmailIdIndex = ItemEmailIdIndex()
cls = DiscriminatorAttribute()
cls.itemEmailIdIndex.query(email_id, limit=1)
DEBUG:pynamodb.connection.base:Calling Query with arguments {'TableName': 'items-hookercookerman', 'KeyConditionExpression': '#0 = :0', 'FilterExpression': '#1 IN (:1)', 'IndexName': 'itemEmailIdIndex', 'Limit': 1, 'ExpressionAttributeNames': {'#0': 'email_id', '#1': 'cls'}, 'ExpressionAttributeValues': {':0': {'S': 'tm58p168k6mbb658fdh530e7f2ci43njakqqb6o1'}, ':1': {'S': 'Item'}}, 'ReturnConsumedCapacity': 'TOTAL'}
Notice here we will get an error with the FilterExpression due to the fact that cls is not in the projection.
Whats the best way around this issue ?