Skip to content

Added tests for $expr#127

Open
vic-tsang wants to merge 1 commit intodocumentdb:mainfrom
vic-tsang:query/expr/tests
Open

Added tests for $expr#127
vic-tsang wants to merge 1 commit intodocumentdb:mainfrom
vic-tsang:query/expr/tests

Conversation

@vic-tsang
Copy link
Copy Markdown
Collaborator

Signed-off-by: Victor Tsang <vitsangp@amazon.com>
@vic-tsang vic-tsang requested a review from a team as a code owner April 21, 2026 06:52
Tests for $expr argument shapes and expression evaluation.

Covers valid argument forms (field references, comparison expressions,
deeply nested operators), system variables ($$ROOT, $$CURRENT, $literal),
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 $$NOW since its also system var?

msg="$or mixing regular query and $expr",
),
QueryTestCase(
id="field_path_through_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.

Add a case with $expr with a field path traversing an array whose elements are scalars (not objects), to cover array-flattening behavior.

msg="$expr with bare $$REMOVE — falsy, no documents match",
),
]

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: $expr inside $not, e.g. {"$expr": {"$not": [{"$gt": ["$a", 0]}]}}

expected=[{"_id": 1, "stats": {"score": 90, "threshold": 80}}],
msg="$expr comparing nested dotted fields from same document",
),
]
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 Decimal128int / double cross-type equivalence. Add at least one case like {"$eq": [Decimal128("1.0"), 1]}.

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.

2 participants