[dynamodb2] Support include projection on indexes (#3498)
* [dynamodb2] Support include projection on indexes * linter
This commit is contained in:
parent
d58d3e2c2e
commit
9e3b23758a
2 changed files with 67 additions and 4 deletions
|
|
@ -292,11 +292,19 @@ class SecondaryIndex(BaseModel):
|
|||
:return:
|
||||
"""
|
||||
if self.projection:
|
||||
if self.projection.get("ProjectionType", None) == "KEYS_ONLY":
|
||||
allowed_attributes = ",".join(
|
||||
self.table_key_attrs + [key["AttributeName"] for key in self.schema]
|
||||
projection_type = self.projection.get("ProjectionType", None)
|
||||
key_attributes = self.table_key_attrs + [
|
||||
key["AttributeName"] for key in self.schema
|
||||
]
|
||||
|
||||
if projection_type == "KEYS_ONLY":
|
||||
item.filter(",".join(key_attributes))
|
||||
elif projection_type == "INCLUDE":
|
||||
allowed_attributes = key_attributes + self.projection.get(
|
||||
"NonKeyAttributes", []
|
||||
)
|
||||
item.filter(allowed_attributes)
|
||||
item.filter(",".join(allowed_attributes))
|
||||
# ALL is handled implicitly by not filtering
|
||||
return item
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue