Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Documentation
-------------

To contribute to the `API documentation
<https://mongoengine-odm.readthedocs.io/>`_
<https://mongoengine-odm.readthedocs.io/apireference.html>`_
just make your changes to the inline documentation of the appropriate
`source code <https://github.com/MongoEngine/mongoengine>`_ or `rst file
<https://github.com/MongoEngine/mongoengine/tree/master/docs>`_ in a
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Examples
Some simple examples of what MongoEngine code looks like:

.. code :: python

import datetime
from mongoengine import *

Expand Down
12 changes: 12 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
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, 3)


def get_version():
Expand Down
35 changes: 20 additions & 15 deletions mongoengine/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/document/test_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tests/document/test_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/document/test_json_serialisation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tests/queryset/test_queryset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
7 changes: 3 additions & 4 deletions tests/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down