Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

port pymongo 4.9 fixes 0 29 1 #2850

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ env:
PYMONGO_4_6: 4.6.2
PYMONGO_4_7: 4.7.3
PYMONGO_4_8: 4.8.0
PYMONGO_4_9: 4.9

MAIN_PYTHON_VERSION: 3.9

Expand Down Expand Up @@ -88,6 +89,9 @@ jobs:
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_8
- python-version: "3.11"
MONGODB: $MONGODB_7_0
PYMONGO: $PYMONGO_4_9
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Development
===========
- (Fill this out as you fix issues and develop your features).


Changes in 0.29.1
=================
- Add support for freshly released pymongo 4.9 #2849

Changes in 0.29.0
=================
- Fix weakref in EmbeddedDocumentListField (causing brief mem leak in certain circumstances) #2827
Expand Down
2 changes: 1 addition & 1 deletion mongoengine/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
)


VERSION = (0, 29, 0)
VERSION = (0, 29, 1)


def get_version():
Expand Down
6 changes: 5 additions & 1 deletion mongoengine/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

from pymongo import MongoClient, ReadPreference, uri_parser
from pymongo.common import _UUID_REPRESENTATIONS
from pymongo.database import _check_name

try:
from pymongo.database_shared import _check_name
except ImportError:
from pymongo.database import _check_name

# DriverInfo was added in PyMongo 3.7.
try:
Expand Down
8 changes: 4 additions & 4 deletions tests/fields/test_datetime_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@

import pytest

from mongoengine import *
from mongoengine import connection
from tests.utils import MongoDBTestCase, get_as_pymongo

try:
import dateutil
except ImportError:
dateutil = None

from mongoengine import *
from mongoengine import connection
from tests.utils import MongoDBTestCase, get_as_pymongo


class TestDateTimeField(MongoDBTestCase):
def test_datetime_from_empty_string(self):
Expand Down
9 changes: 5 additions & 4 deletions tests/queryset/test_queryset_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ class Bar(Document):
bars = Bar.objects.read_preference(
ReadPreference.SECONDARY_PREFERRED
).aggregate(pipeline)
assert (
bars._CommandCursor__collection.read_preference
== ReadPreference.SECONDARY_PREFERRED
)
if hasattr(bars, "_CommandCursor__collection"):
read_pref = bars._CommandCursor__collection.read_preference
else: # pymongo >= 4.9
read_pref = bars._collection.read_preference
assert read_pref == ReadPreference.SECONDARY_PREFERRED

def test_queryset_aggregation_framework(self):
class Person(Document):
Expand Down
7 changes: 6 additions & 1 deletion tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import uuid

import pymongo
import pymongo.database
import pymongo.mongo_client
import pytest
from bson.tz_util import utc
from pymongo import MongoClient, ReadPreference
Expand Down Expand Up @@ -608,7 +610,10 @@ def test_connect_with_replicaset_via_kwargs(self):
connection kwargs
"""
c = connect(replicaset="local-rs")
assert c._MongoClient__options.replica_set_name == "local-rs"
if hasattr(c, "_MongoClient__options"):
assert c._MongoClient__options.replica_set_name == "local-rs"
else: # pymongo >= 4.9
assert c._options.replica_set_name == "local-rs"
db = get_db()
assert isinstance(db, pymongo.database.Database)
assert db.name == "test"
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4,mg432,mg441,mg462,mg473,mg480}
envlist = pypy3-{mg34,mg36,mg39,mg311,mg312,mg4,mg432,mg441,mg462,mg473,mg480,mg49}
skipsdist = True

[testenv]
Expand All @@ -16,5 +16,6 @@ deps =
mg462: pymongo>=4.6,<4.7
mg473: pymongo>=4.7,<4.8
mg480: pymongo>=4.8,<4.9
mg49: pymongo>=4.9,<5.0
setenv =
PYTHON_EGG_CACHE = {envdir}/python-eggs
Loading