Skip to content

fix(core): read a bare size as an attribute name - #1146

Open
LeeroyHannigan wants to merge 1 commit into
mainfrom
fix/1028-size-as-name
Open

LeeroyHannigan wants to merge 1 commit into
mainfrom
fix/1028-size-as-name

Conversation

@LeeroyHannigan

@LeeroyHannigan LeeroyHannigan commented Nov 18, 2026 •

Copy link
Copy Markdown
Collaborator

What

ExtendDB now reads a bare size as an attribute name in a projection, condition, filter, key condition and update expression, as DynamoDB does. Where ( follows size, it is still the function. A SearchConditionExpression still refuses a bare size, since DynamoDB's answer there is not measured.

Before this change, ExtendDB refused size as a reserved word in every expression, because SIZE is on the reserved word list.

is_reserved in crates/core/src/expression/reserved_words.rs now returns false for size. Its old body is now is_listed, which the SearchConditionExpression check in search_condition_phases.rs calls. SIZE stays on the list, as on DynamoDB's published list of reserved words.

Why

These are DynamoDB's answers, measured in us-east-1 on 14, 16 and 18 November 2026. Each request went out twice and got the same answer both times.

Request DynamoDB
GetItem, ProjectionExpression size, a.SIZE the item with size and a.SIZE
GetItem, ProjectionExpression size.x, b, where size is a map size.x and b
UpdateItem, SET size = :n and SET a = size, on a table that does not exist ResourceNotFoundException
UpdateItem, REMOVE size the update, with size removed
Query, KeyConditionExpression size = :v ValidationException: Query condition missed key schema element: pk
PutItem, ConditionExpression size = :v ConditionalCheckFailedException
PutItem, ConditionExpression attribute_exists(size) the put where the item has size, else ConditionalCheckFailedException
Query and Scan, FilterExpression size = :v the filter, with size read as a name

SIZE = :v in a key condition on a table whose sort key is size, size[0], #n.size and size (b) get DynamoDB's answers too. The word status stays reserved in a projection, a condition, a key condition and an update expression.

Closes #1028

Testing done

  • cargo test -p extenddb-core --lib: 1148 passed, 1 ignored.
  • cargo test -p extenddb-engine --lib: 870 passed.
  • cargo test -p extenddb-server --lib: 513 passed. The 5 backup_store tests that check file permissions fail on the test host, where a parent directory belongs to another user. This PR does not change backup_store.rs.
  • cargo +1.97.0 clippy -p extenddb-core -p extenddb-engine -p extenddb-server --all-targets -- -D warnings and cargo +1.97.0 fmt --all -- --check are clean.
  • Against ExtendDB on SQLite, 5 wire test files that send reserved words passed 323 tests. The new test TestSizeIsAnAttributeName in tests/test_expression_error_prefix.py sends 11 rows, and they fail against origin/main.
  • The core test size_with_no_paren_after_it_is_an_attribute_name reads the rows above. With the change reverted, it fails on the size, a.SIZE row.
  • The last change cut two test rows and six comment lines. After it, cargo test -p extenddb-core --lib passed 1148, and clippy on the core and fmt are clean. The other runs above are on the commit before that change.

Line counts: production +9 -2, tests +213.

Not in this PR, each in an open issue or PR:

Other open PRs:

Checklist

  • I have read CONTRIBUTING.md
  • All tests pass (cargo test --workspace)
  • Code is formatted (cargo fmt --check)
  • Clippy is clean (cargo clippy -- -W clippy::pedantic)
  • I have added or updated tests for new functionality
  • I have updated documentation if behavior changed
  • Breaking changes are noted below (if any)
  • If this changes the wire protocol, Storage trait, auth model, on-disk
    format, or public CLI surface, an RFC has been accepted or is linked
    below. Otherwise, an ADR captures the decision (link below).

ADR / RFC: n/a


By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache License 2.0 and I agree to the Developer Certificate of
Origin (DCO). See CONTRIBUTING.md for details.

Amazon DynamoDB reads `size` as the function only where `(` follows it.
Everywhere else in a projection, condition, filter, key condition or
update expression it reads `size` as an attribute name. ExtendDB refused
the word there as reserved.

Measured in us-east-1 on 2026-11-14, 2026-11-16 and 2026-11-18, with
each request sent twice. The service returned the projected `size` and
`a.SIZE`, and the projected `size.x` of a map. It answered `SET size = :n`
and `SET a = size` on a missing table with ResourceNotFoundException.
It answered the key condition `size = :v` with "Query condition missed
key schema element: pk". It also read `size` as a name in a condition,
in a Query and a Scan filter, and in `REMOVE size`.

The reserved word check now passes `size`. The word `status` stays
reserved. A bare name in a SearchConditionExpression is still checked
against the whole list, `size` included, since the service's answer
there is not measured.

Fixes #1028.

@LJMart11 LJMart11 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed at d7de36b. Core (1148), engine (870) and server (518) lib tests and the 11 new wire rows passed; both new guards fail a test when removed. Review covered the reserved-word change and the PR body's counts.

Docs — outside the diff

  1. crates/core/src/expression/reserved_words.rs:38 — Update the test counts in the PR body: it gives 513 for cargo test -p extenddb-server --lib and says 5 backup_store tests fail on the test host. On this head that command ran 518 passed, 0 failed (the 5 failures are host-specific). Re-run and restate the count, or drop the host-failure note.

@navareamol navareamol self-assigned this Dec 3, 2026

@navareamol navareamol left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The description says the word status stays reserved in a projection, a condition, a key condition and an update expression, and that a key condition on a table whose sort key is size, size[0], #n.size and size (b) get DynamoDB's answers. I think no test in this PR pins either claim. The wire row key-condition-size is a Query on a table without a size sort key, and neither the unit test nor the wire test has a status row. On a build of this head, status is still refused in a projection and a condition, and a key condition on a sort key named size works, so the behaviour looks right. A later change that breaks status or the sort key case would pass these tests.

Can you add rows for status in each of the four expression kinds, for a key condition on a sort key named size, and for size (b) with a space before the bracket?

I will approve once those rows are in.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ProjectionExpression and UpdateExpression refuse size as a reserved word where it names an attribute, and DynamoDB reads it as a name

3 participants