Skip to content

Add $type tests#691

Open
PatersonProjects wants to merge 6 commits into
documentdb:mainfrom
PatersonProjects:type_tests
Open

Add $type tests#691
PatersonProjects wants to merge 6 commits into
documentdb:mainfrom
PatersonProjects:type_tests

Conversation

@PatersonProjects

Copy link
Copy Markdown
Contributor

This PR adds the tests for the $type operator. They were originally authored by @danielfrankcom.

Ref: Issue #15

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
…-tests

Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
Signed-off-by: PatersonProjects <keldonhoff@gmail.com>
@PatersonProjects PatersonProjects requested a review from a team as a code owner July 15, 2026 23:03

@danielfrankcom danielfrankcom 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.

Looks good, comments are minor.


# Property [Core BSON Type Mapping]: each BSON type produces a specific,
# distinct type name string.
TYPE_CORE_BSON_TESTS: list[ExpressionTestCase] = [

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.

Not sure we need this given TYPE_STORED_FIELD_TESTS, the coverage is equivalent.

TYPE_ARRAY_LITERAL_TESTS: list[ExpressionTestCase] = [
ExpressionTestCase(
"array_single_element_literal_unwrap",
expression={"$type": ["hello"]},

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.

Would be good to also cover a case like {"$type": ["$val"]} given the array unwrapping is not consistent behavior across operators and combining it with field path resolution might do something weird.

@documentdb-triage-tool documentdb-triage-tool Bot added compatibility test Compatibility test related enhancement New feature or request labels Jul 15, 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 (1007+0 LOC, 7 files); LLM: Adds new test cases for the $type operator under the compatibility tests path, expanding test coverage for a specific MongoDB operator.

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.

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