Skip to content

Added array tests for $elemMatch#151

Open
vic-tsang wants to merge 1 commit intodocumentdb:mainfrom
vic-tsang:arrays/elemMatch/tests
Open

Added array tests for $elemMatch#151
vic-tsang wants to merge 1 commit intodocumentdb:mainfrom
vic-tsang:arrays/elemMatch/tests

Conversation

@vic-tsang
Copy link
Copy Markdown
Collaborator

Signed-off-by: Victor [C] Tsang <vitsangp@amazon.com>
@vic-tsang vic-tsang requested a review from a team as a code owner April 30, 2026 16:40
@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels Apr 30, 2026
@documentdb-triage-tool
Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, enhancement
Project fields suggested: Component test-coverage · Priority P2 · Effort L · Status Needs Review
Confidence: 0.85 (mixed)

Reasoning

component from path globs (test-coverage); effort from diff stats (1403+17 LOC, 6 files); LLM: Adds new array test cases for $elemMatch operator, expanding compatibility test coverage as part of a tracked issue.

If a label is wrong, remove it manually and ping @patty-chow so the rules can be tuned. The bot will not re-label items that already have component labels.

msg="Double argument should fail",
),
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

  • test for $elemMatch with empty string key {"": {"$elemMatch": {...}}} — edge case.
  • test for $elemMatch with dotted field containing $ prefix (invalid field path).
  • test for $elemMatch at top level without field {"$elemMatch": {...}} — spec requires it inside a : {} expression; bare usage should error.

],
expected=[{"_id": 1, "a": [1, "a", True, None]}],
msg="Should match in mixed-type array",
),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should we add mixed array type with array of array value

),
]

ALL_OPERATOR_TESTS = COMPARISON_TESTS + EMBEDDED_DOC_TESTS + NESTED_ELEMMATCH_TESTS
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you add test for $elemMatch with $bitsAllSet/$bitsAnySet/$bitsAllClear/$bitsAnyClear

FLOAT_NEGATIVE_INFINITY,
)

NULL_AND_MISSING_TESTS: list[QueryTestCase] = [
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Missing Decimal128("NaN") inside $elemMatch

{"_id": 2, "a": [1]},
],
expected=[{"_id": 1, "a": [FLOAT_NEGATIVE_INFINITY]}],
msg="$eq -Infinity matches -Infinity",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

MIssing test for Decimal128("Infinity")

msg="$all with mixed regex and $elemMatch should error",
),
]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you add test for $all with nested $elemMatch containing nested $elemMatch

],
expected=[{"_id": 1, "a": [{"x": 3, "y": 2}]}],
msg="Implicit $and via multiple conditions",
),
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

can you add test for $and with $elemMatch

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

Labels

compatibility test Compatibility test related enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants