Merge pull request #2819 from bblommers/dynamodb_global_index_ordering

Dynamodb - Global index ordering
This commit is contained in:
Steve Pulec 2020-03-19 19:39:09 -05:00 committed by GitHub
commit 14b2811157
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 64 additions and 1 deletions

View file

@ -988,8 +988,13 @@ class Table(BaseModel):
if index_name:
if index_range_key:
# Convert to float if necessary to ensure proper ordering
def conv(x):
return float(x.value) if x.type == "N" else x.value
results.sort(
key=lambda item: item.attrs[index_range_key["AttributeName"]].value
key=lambda item: conv(item.attrs[index_range_key["AttributeName"]])
if item.attrs.get(index_range_key["AttributeName"])
else None
)