Skip to content

Pagination for indexes does not work #100

Open
@iisulop

Description

@iisulop

It seems pagination does not work properly for indexes. When doing scans on tables they do work. The problem appears when trying to paginate using last and again or recursive.

from faker import Faker
import uuid as uuid
from dynamorm import (
    DynaModel,
    GlobalIndex,
    ProjectAll,
)
from marshmallow import fields

faker = Faker()

class BigProblem(DynaModel):
    class Table:
        name = 'example_big_query_problem_table_1'
        hash_key = 'uuid'

    class TypeIndex(GlobalIndex):
        """Index for quickly accessing individual tags"""
        name = 'type_index'
        hash_key = 'type'
        projection = ProjectAll()

    class Schema:
        uuid = fields.Str(missing=lambda: str(uuid.uuid4()))
        type = fields.Str(missing=lambda: 'data')
        data = fields.List(fields.Str())


BigProblem.Table.delete()
if not BigProblem.Table.exists:
    BigProblem.Table.create(wait=True)
    for _ in range(1000):
        BigProblem(data=[faker.name() for _ in range(100)]).save()


type_it = BigProblem.TypeIndex.query(type='data')
types = list(type_it)
while type_it.last is not None:
    type_it.again()
    print(len(types))
    types.extend(type_it)
print(len(types))

Expected types to include all the rows in the table.

Result:

File "minimal_query_problem.py", line 41, in
types.extend(type_it)
...
File ".venv/lib/python3.7/site-packages/botocore/client.py", line 586, in _make_api_call
raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (ValidationException) when calling the Query operation: KeyConditionExpressions must only contain one condition per key

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions