Skip to content

Fix matching whole array when using $in operator#919

Open
hazard595 wants to merge 1 commit into
mongomock:developfrom
hazard595:fix/in-op-search-array
Open

Fix matching whole array when using $in operator#919
hazard595 wants to merge 1 commit into
mongomock:developfrom
hazard595:fix/in-op-search-array

Conversation

@hazard595

@hazard595 hazard595 commented Apr 17, 2025

Copy link
Copy Markdown

Selecting a list value in $in query fails in mongomock, but works in MongoDB.

Similar to issue fixed in PR #91, but for the case when list of lists in passed as value for $in query.

For example when the doc is
{'array_field': ['abc']} and the query is {'array_field': {'$in': [['abc']]}} mongomock returns an empty result, while the same query works in MongoDB.

@codecov

codecov Bot commented Apr 17, 2025

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.07%. Comparing base (d5c0e8b) to head (d174257).
⚠️ Report is 6 commits behind head on develop.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop     #919   +/-   ##
========================================
  Coverage    96.07%   96.07%           
========================================
  Files           35       35           
  Lines        10118    10119    +1     
========================================
+ Hits          9721     9722    +1     
  Misses         397      397           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@hazard595 hazard595 marked this pull request as ready for review April 17, 2025 22:06
engFelipeMonteiro added a commit to engFelipeMonteiro/mongomock-ng that referenced this pull request May 21, 2026
Replicates mongomock#692closes #191 (immutable projection)
Replicates mongomock#795closes #184 ($in comparison)
Replicates mongomock#819closes #178 ($slice parsing)
Replicates mongomock#847closes #170 ($addToSet $each)
Replicates mongomock#860closes #169 ($redact support)
Replicates mongomock#895closes #158 (collation signature)
Replicates mongomock#919closes #154 ($in array matching)
Replicates mongomock#933closes #147 (BulkOpBuilder sort)
Replicates mongomock#936closes #145 (NaN handling)
Replicates mongomock#944closes #144 (utcnow deprecation)

Version bump: 7.4.0 -> 7.4.1
engFelipeMonteiro added a commit to engFelipeMonteiro/mongomock-ng that referenced this pull request May 21, 2026
## [7.4.1] - 2026-05-21
### Changed
- Drop Python 3.14 from test matrix and classifiers — not yet stable, incompatible with runtime dependencies
- Add pymongo 4.12.0 and 4.14.0 to hatch-test matrix for broader compatibility coverage

### Fixed
- TTL document expiry no longer crashes on Python 3.13 — normalize naive datetimes to UTC-aware before subtraction in `_value_meets_expiry` (store.py)
- Replace deprecated `datetime.utcfromtimestamp` with `datetime.fromtimestamp(..., tz=timezone.utc)` in aggregation `$convert` to date handlers (aggregate.py)
- Replace deprecated `datetime.utcnow()` with `datetime.now(timezone.utc).replace(tzinfo=None)` in helpers and test suite
- Fix hatch-test matrix so environment `hatch-test.*-4.11.0` correctly installs `pymongo==4.11.0` (missing `if` clause)
- `find()` projection no longer mutates original document data (mongomock#692closes #191)
- `$in` operator correctly handles empty-list values (mongomock#795closes #184)
- `$slice` aggregation operator evaluates arguments as expressions (mongomock#819closes #178)
- `$addToSet` with `$each` correctly deduplicates repeated values across runs (mongomock#847closes #170)
- `$redact` aggregation stage now supported (mongomock#860closes #169)
- `Cursor.collation` matches PyMongo 4.x method signature (mongomock#895closes #158)
- `$in` operator matches whole arrays in document values (mongomock#919closes #154)
- `BulkOperationBuilder.add_update` and `_update` support `sort` parameter (mongomock#933closes #147)
- NaN comparison handling in filter `$eq` operator (mongomock#936closes #145)
- Replace deprecated `datetime.utcnow` with `datetime.now(UTC)` on Python 3.11+ (mongomock#944closes #144)
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.

1 participant