Skip to content

Conversation

@arunsureshkumar
Copy link

This PR contributes to #2902 , which tracks the ongoing effort to add native async support to MongoEngine using PyMongo’s official async API (>= 4.14).

It includes foundational changes toward async-first workflows, improvements to select_related via aggregation pipelines, and related updates across core internals, tests, CI, and documentation.

Notes

  • Async support is native, not layered on top of sync behavior
  • Focus on unified sync/async code paths and improved performance
  • Version and compatibility changes apply (see issue for details)

📌 Details, motivation, and full scope are documented in the issue: #2902
🚧 Work is still in progress — feedback is welcome.

arunsureshkumar and others added 30 commits December 27, 2025 22:43
- Refactored the core ORM to support PyMongo’s native async API
- Unified sync and async code paths across documents, querysets, and transactions
- Replaced legacy async implementations
- Removed deprecated and compatibility code

BREAKING CHANGE:
- Removed legacy async behavior
- Removed LazyReferenceField
- Removed GenericLazyReferenceField
- GenericReferenceField now requires `choices`
- Dropped support for PyMongo < 4.14
- Dropped support for MongoDB < 4.2
BaseQuerySet is now defined only in the synchronous queryset implementation.
add: TestQuerysetLookupMatch
…uilder stages

- Extract query normalization, match planning, lookup planning, stage building, and tail stages
- Introduce clear aggregation pipeline architecture aligned with MongoDB stages
- Reduce PipelineBuilder to a small orchestration layer
- Improve readability, isolation, and long-term maintainability
…ilter-only lookups

Body:
	•	refactor StageBuilder traversal/handlers for readability
	•	keep $lookup unfiltered for correct hydration; apply foreign predicates via local $filter
	•	emit explicit _missing_reference markers so deref raises DoesNotExist
	•	reduce duplication with shared helpers and structured dispatch
- Normalize refIds generation across scalar and container fields
- Use reduce-based flattening for ListField reference lookups
- Ensure missing references emit `{_missing_reference, _ref}` only
- Fix select_related pipelines to match MongoDB 4.2+ semantics
- Expand pipeline builder tests for nested and container references
…ort, updated installation steps, supported MongoDB versions, and improved examples.
…project

- Use uv for dependency management and builds
- Simplify GitHub Actions matrix and MongoDB setup
- Replace custom CI scripts with uv-based dependency management, actions
- Match tox environment with GitHub Action matrix
abhinand-c and others added 13 commits January 2, 2026 21:33
- Corrected version number in docs and package
- disabled coveralls
- fix tox not running selected env only
- Parallel runner support for coveralls

TODO:
- Split github action
…registry cleanup

- Update assertions to use `await` where needed for async compatibility.
- Introduce `_DocumentRegistry.clear()` and `_CollectionRegistry.clear()` calls in test setups and teardowns.
- Normalize test workflows to ensure proper registry state management across synchronous and asynchronous environments.
- Simplify pipeline builder tests by removing unnecessary async and ensuring compatibility with recent updates.
…ts, and async example usage in `query_counter` and `async_query_counter`
@abhinand-c
Copy link

@bagerard @rozza @hmarr
Can you help us with review and feedbacks?

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