Skip to content

Commit

Permalink
Update uuidRepresentation warnings with "unspecified" as the future d…
Browse files Browse the repository at this point in the history
…efault
  • Loading branch information
ShaneHarvey committed Mar 1, 2023
1 parent d0e7564 commit 9b879d1
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions mongoengine/base/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ def to_json(self, *args, **kwargs):
"No 'json_options' are specified! Falling back to "
"LEGACY_JSON_OPTIONS with uuid_representation=PYTHON_LEGACY. "
"For use with other MongoDB drivers specify the UUID "
"representation to use.",
"representation to use. This will be changed to "
"uuid_representation=UNSPECIFIED in a future release.",
DeprecationWarning,
)
kwargs["json_options"] = LEGACY_JSON_OPTIONS
Expand Down Expand Up @@ -480,7 +481,8 @@ def from_json(cls, json_data, created=False, **kwargs):
"No 'json_options' are specified! Falling back to "
"LEGACY_JSON_OPTIONS with uuid_representation=PYTHON_LEGACY. "
"For use with other MongoDB drivers specify the UUID "
"representation to use.",
"representation to use. This will be changed to "
"uuid_representation=UNSPECIFIED in a future release.",
DeprecationWarning,
)
kwargs["json_options"] = LEGACY_JSON_OPTIONS
Expand Down
2 changes: 1 addition & 1 deletion mongoengine/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ def _get_connection_settings(
"For compatibility with other MongoDB drivers this should be "
"specified as 'standard' or '{java,csharp}Legacy' to work with "
"older drivers in those languages. This will be changed to "
"'standard' in a future release.",
"'unspecified' in a future release.",
DeprecationWarning,
)
kwargs["uuidRepresentation"] = "pythonLegacy"
Expand Down
2 changes: 2 additions & 0 deletions mongoengine/pymongo_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@

PYMONGO_VERSION = tuple(pymongo.version_tuple[:2])

# This will be changed to UuidRepresentation.UNSPECIFIED in a future
# (breaking) release.
if PYMONGO_VERSION >= (4,):
LEGACY_JSON_OPTIONS = json_util.LEGACY_JSON_OPTIONS.with_options(
uuid_representation=binary.UuidRepresentation.PYTHON_LEGACY,
Expand Down
3 changes: 2 additions & 1 deletion mongoengine/queryset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,8 @@ def to_json(self, *args, **kwargs):
"No 'json_options' are specified! Falling back to "
"LEGACY_JSON_OPTIONS with uuid_representation=PYTHON_LEGACY. "
"For use with other MongoDB drivers specify the UUID "
"representation to use.",
"representation to use. This will be changed to "
"uuid_representation=UNSPECIFIED in a future release.",
DeprecationWarning,
)
kwargs["json_options"] = LEGACY_JSON_OPTIONS
Expand Down

0 comments on commit 9b879d1

Please sign in to comment.