Skip to content

Queries: count() of projected reads fails, and sort key fields shared with the partition key are refused #85

Closed

Description

@fctl-sh

Priority: medium.

  • count() of a projected read always fails (query.py, count()): it drops the projection but sends its attribute names, so Note.query(client, user_id="u1").project(Note.text).count() fails with ValidationException: Value provided in ExpressionAttributeNames unused in expressions, and a scan without other expressions with "ExpressionAttributeNames can only be specified when using expressions". table.query(...).project("text").count() fails the same way.
  • scan().after(cursor).segments(n).count() applies one segment's cursor to every segment (query.py, count()): iteration refuses this ("a parallel scan reads every segment from its start"), count() returns a wrong number (35 for 40 items).
  • query() and count() refuse sort key fields that repeat a partition key field (repository.py, building the partition key consumes the shared field): with pk "ORG#{org_id}" and sk "MEMBER#{org_id}#{user_id}", Membership.get(client, org_id="o1", user_id="u1") works but Membership.query(client, org_id="o1", user_id="u1") raises ValueError: ... unexpected arguments user_id; the same for index keys such as "STATUS#{status}"/"{status}#{placed_at}".

Found in a review of the library for bugs (fctl session); the fixes that fit in its ten pull requests are #61 to #65, #67 to #70 and #72.

Activity

  1. added
    bug
    on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions