diff --git a/.github/workflows/github-actions.yml b/.github/workflows/github-actions.yml index c76e69fca..47c705050 100644 --- a/.github/workflows/github-actions.yml +++ b/.github/workflows/github-actions.yml @@ -87,7 +87,7 @@ jobs: - name: Send coverage to Coveralls env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - COVERALLS_SERVICE_NAME: github + COVERALLS_SERVICE_NAME: github-actions if: ${{ matrix.python-version == env.MAIN_PYTHON_VERSION }} run: coveralls diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 678ef7654..6a7e267c7 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -95,7 +95,7 @@ Documentation ------------- To contribute to the `API documentation -`_ +`_ just make your changes to the inline documentation of the appropriate `source code `_ or `rst file `_ in a diff --git a/README.rst b/README.rst index 1b675012c..4d21b4c0c 100644 --- a/README.rst +++ b/README.rst @@ -83,6 +83,7 @@ Examples Some simple examples of what MongoEngine code looks like: .. code :: python + import datetime from mongoengine import * diff --git a/docs/changelog.rst b/docs/changelog.rst index fab41b7b6..b9135b218 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -30,6 +30,18 @@ Development - Improve error message in case a document assigned to a ReferenceField wasn't saved yet #1955 - BugFix - Take `where()` into account when using `.modify()`, as in MyDocument.objects().where("this[field] >= this[otherfield]").modify(field='new') #2044 +Changes in 0.29.3 +================= +- Remove mentions of mongoengine[dot]org has we no longer own it #2905 + +Changes in 0.29.2 +================= +- fixes relted with + +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 diff --git a/mongoengine/__init__.py b/mongoengine/__init__.py index 3b2a884b6..bda28f1ee 100644 --- a/mongoengine/__init__.py +++ b/mongoengine/__init__.py @@ -29,7 +29,7 @@ ) -VERSION = (0, 29, 0) +VERSION = (0, 29, 3) def get_version(): diff --git a/mongoengine/connection.py b/mongoengine/connection.py index 9c3330c3d..4728cb377 100644 --- a/mongoengine/connection.py +++ b/mongoengine/connection.py @@ -142,16 +142,21 @@ def _get_connection_settings( # PyMongo < 4.14 returned a case-insensitive options mapping, but # PyMongo >= 4.14 returns a plain dict with canonical option names. # Normalize keys so lookups stay compatible across supported versions. - uri_options = { + normalized_uri_options = { key.lower(): value for key, value in uri_dict["options"].items() } - if "replicaset" in uri_options: - conn_settings["replicaSet"] = uri_options["replicaset"] - if "authsource" in uri_options: - conn_settings["authentication_source"] = uri_options["authsource"] - if "authmechanism" in uri_options: - conn_settings["authentication_mechanism"] = uri_options["authmechanism"] - if "readpreference" in uri_options: + + if "replicaset" in normalized_uri_options: + conn_settings["replicaSet"] = normalized_uri_options["replicaset"] + if "authsource" in normalized_uri_options: + conn_settings["authentication_source"] = normalized_uri_options[ + "authsource" + ] + if "authmechanism" in normalized_uri_options: + conn_settings["authentication_mechanism"] = normalized_uri_options[ + "authmechanism" + ] + if "readpreference" in normalized_uri_options: read_preferences = ( ReadPreference.NEAREST, ReadPreference.PRIMARY, @@ -165,7 +170,7 @@ def _get_connection_settings( # int (e.g. 3). # TODO simplify the code below once we drop support for # PyMongo v3.4. - read_pf_mode = uri_options["readpreference"] + read_pf_mode = normalized_uri_options["readpreference"] if isinstance(read_pf_mode, str): read_pf_mode = read_pf_mode.lower() for preference in read_preferences: @@ -176,23 +181,23 @@ def _get_connection_settings( ReadPrefClass = preference.__class__ break - if "readpreferencetags" in uri_options: + if "readpreferencetags" in normalized_uri_options: conn_settings["read_preference"] = ReadPrefClass( - tag_sets=uri_options["readpreferencetags"] + tag_sets=normalized_uri_options["readpreferencetags"] ) else: conn_settings["read_preference"] = ReadPrefClass() - if "authmechanismproperties" in uri_options: - conn_settings["authmechanismproperties"] = uri_options[ + if "authmechanismproperties" in normalized_uri_options: + conn_settings["authmechanismproperties"] = normalized_uri_options[ "authmechanismproperties" ] - if "uuidrepresentation" in uri_options: + if "uuidrepresentation" in normalized_uri_options: REV_UUID_REPRESENTATIONS = { v: k for k, v in _UUID_REPRESENTATIONS.items() } conn_settings["uuidrepresentation"] = REV_UUID_REPRESENTATIONS[ - uri_options["uuidrepresentation"] + normalized_uri_options["uuidrepresentation"] ] else: resolved_hosts.append(entity) diff --git a/setup.py b/setup.py index 7f551e9ca..5865bb56f 100644 --- a/setup.py +++ b/setup.py @@ -60,7 +60,7 @@ def get_version(version_tuple): author_email="harry.marr@gmail.com", maintainer="Bastien Gerard", maintainer_email="bast.gerard@gmail.com", - url="https://mongoengine-odm.readthedocs.io/", + url="https://github.com/MongoEngine/mongoengine", download_url="https://github.com/MongoEngine/mongoengine/tarball/master", license="MIT", include_package_data=True, diff --git a/tests/document/test_dynamic.py b/tests/document/test_dynamic.py index cf11798a7..0453b650f 100644 --- a/tests/document/test_dynamic.py +++ b/tests/document/test_dynamic.py @@ -211,7 +211,7 @@ class Doc(DynamicDocument): Doc.drop_collection() doc = Doc() - embedded_doc_1 = Embedded(content="https://mongoengine-odm.readthedocs.io/") + embedded_doc_1 = Embedded(content="http://garbage.com") embedded_doc_1.validate() embedded_doc_2 = Embedded(content="this is not a url") diff --git a/tests/document/test_instance.py b/tests/document/test_instance.py index cf1c2e61b..b7bf2179c 100644 --- a/tests/document/test_instance.py +++ b/tests/document/test_instance.py @@ -1499,7 +1499,7 @@ class Doc(Document): map_field = MapField(IntField(), default=lambda: {"simple": 1}) decimal_field = DecimalField(default=1.0) complex_datetime_field = ComplexDateTimeField(default=datetime.now) - url_field = URLField(default="https://mongoengine-odm.readthedocs.io/") + url_field = URLField(default="http://garbage.com") dynamic_field = DynamicField(default=1) generic_reference_field = GenericReferenceField( default=lambda: Simple().save() diff --git a/tests/document/test_json_serialisation.py b/tests/document/test_json_serialisation.py index 93f6729c3..a8d573548 100644 --- a/tests/document/test_json_serialisation.py +++ b/tests/document/test_json_serialisation.py @@ -79,7 +79,7 @@ class Doc(Document): map_field = MapField(IntField(), default=lambda: {"simple": 1}) decimal_field = DecimalField(default=1.0) complex_datetime_field = ComplexDateTimeField(default=datetime.now) - url_field = URLField(default="https://mongoengine-odm.readthedocs.io/") + url_field = URLField(default="http://garbage.com") dynamic_field = DynamicField(default=1) generic_reference_field = GenericReferenceField( default=lambda: Simple().save() diff --git a/tests/queryset/test_queryset.py b/tests/queryset/test_queryset.py index 7a553d126..d9a9d8842 100644 --- a/tests/queryset/test_queryset.py +++ b/tests/queryset/test_queryset.py @@ -5207,7 +5207,7 @@ class Doc(Document): map_field = MapField(IntField(), default=lambda: {"simple": 1}) decimal_field = DecimalField(default=1.0) complex_datetime_field = ComplexDateTimeField(default=datetime.datetime.now) - url_field = URLField(default="https://mongoengine-odm.readthedocs.io/") + url_field = URLField(default="http://garbage.com") dynamic_field = DynamicField(default=1) generic_reference_field = GenericReferenceField( default=lambda: Simple().save() diff --git a/tests/test_connection.py b/tests/test_connection.py index 87af2b517..c7343539d 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -663,10 +663,9 @@ def test_multiple_connection_settings(self): mongo_connections["t2"].server_info() assert mongo_connections["t1"].address[0] == "localhost" - assert mongo_connections["t2"].address[0] in ( - "localhost", - "127.0.0.1", - ) # weird but there is a discrepancy in the address in replicaset setup + assert mongoengine.connection._connection_settings["t2"]["host"] == [ + "127.0.0.1" + ] assert mongo_connections["t1"].read_preference == ReadPreference.PRIMARY assert ( mongo_connections["t2"].read_preference == ReadPreference.PRIMARY_PREFERRED