Skip to content

Fix Issue #202: Add $bitAnd operator expression compatibility tests#662

Open
krishnasai453 wants to merge 7 commits into
documentdb:mainfrom
krishnasai453:fix-issue-202-add_bitAnd_compatibility_test
Open

Fix Issue #202: Add $bitAnd operator expression compatibility tests#662
krishnasai453 wants to merge 7 commits into
documentdb:mainfrom
krishnasai453:fix-issue-202-add_bitAnd_compatibility_test

Conversation

@krishnasai453

Copy link
Copy Markdown

Description

This PR resolves failing compatibility tests for the $bitAnd operator in test_expression_bitAnd_additional.py.

Why this is needed

Under MongoDB and DocumentDB specifications, the $bitAnd aggregation operator only supports int and long operands. Passing an array expression (such as [["$a", "$b"], 3]) or an object expression (such as [{"x": "$a", "y": "$b"}, 0]) evaluates to array/object structures, which are non-numeric types. These operations should fail with a type mismatch rather than succeed.

What changed

  • Updated ARRAY_EXPRESSION_TESTS and OBJECT_EXPRESSION_TESTS in test_expression_bitAnd_additional.py to expect TYPE_MISMATCH_ERROR (code 14) instead of assuming successful evaluation.
  • Forwarded the error_code parameter to assert_expression_result in test_bitAnd_expression_additional.
  • Removed the untracked template file test_expression_bitAnd_testing_strategy.txt.

How to test

Run the bitwise operator tests locally:

pytest documentdb_tests/compatibility/tests/core/operator/expressions/bitwise/bitAnd/test_expression_bitAnd.py 
pytest documentdb_tests/compatibility/tests/core/operator/expressions/bitwise/bitAnd/test_expression_bitAnd_additional.py

@krishnasai453 krishnasai453 requested a review from a team as a code owner July 1, 2026 03:46
@krishnasai453

Copy link
Copy Markdown
Author

Hi @ this is my first contribution to this project. I've fixed issue #202 by correcting the additional compatibility tests for the $bitAnd expression operator. Because $bitAnd only accepts numeric integer and long operands, array and object inputs are now properly asserted to reject with a type mismatch error (TYPE_MISMATCH_ERROR).
Would appreciate a review when you have time!

@documentdb-triage-tool documentdb-triage-tool Bot added bug Something isn't working compatibility test Compatibility test related labels Jul 1, 2026
@documentdb-triage-tool

Copy link
Copy Markdown

🤖 Auto-triaged by documentdb-triage-tool.

Applied: compatibility test, bug
Project fields suggested: Component test-coverage · Priority P2 · Effort M · Status Needs Review
Confidence: 0.30 (deterministic)

Reasoning

component from path globs (test-coverage); effort from diff stats (126+0 LOC, 2 files); LLM failed: Invalid response body while trying to fetch https://api.anthropic.com/v1/messages: Premature close

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

bug Something isn't working compatibility test Compatibility test related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant