v1.0.0
I'm excited to announce ODMantic v1.0.0, with Pydantic v2 support! 🎉
This release brings a range of changes that are aligned with the new Pydantic architecture.
Keeping a maintainable and healthy codebase was especially important.
Thus from now on, ODMantic will not support Python 3.7, Pydantic V1, and Motor 2.x anymore.
Overall, integrating with Pydantic v2 brings around 30% performance improvements on
common operations. ⚡️⚡️⚡️
We have a lot of room to improve the performance further now that we only support Pydantic v2.
There is also a 300% 👀 improvement on the bulk saves crafted by @tiangolo that will be merged soon! 🚀
Special thanks to @tiangolo for his help on this release and for saving me a lot of time
figuring out a particularly annoying bug!
Check out the migration guide to
upgrade your codebase and enjoy this new release!
Breaking changes
-
Support for Python 3.7, Pydantic v1 and Motor 2.x has been dropped
-
Optional[T]
doesn't have aNone
implicit default value anymore -
Model.copy
doesn't support theexclude
andinclude
kwargs anymore -
odmantic.Field
doesn't accept extra kwargs anymore since it's slated to be removed in Pydantic -
The
Config
class is no longer supported and themodel_config
dict should be used instead -
DocumentParsingError
is no longer a subclass ofValidationError
-
The
__bson__
class method is no longer supported to define BSON encoders on custom types. The new method to customize BSON encoding is to use theWithBSONSerializer
annotation. -
Decimals (
decimal.Decimal
andbson.Decimal128
) are now serialized as strings in JSON documents -
Custom JSON encoders(defined with the
json_encoders
config option) are no longer effective onodmantic.bson
types. Annotated types withpydantic.PlainSerializer
should be used instead.
Removals
-
AIOEngineDependency
has been removed since it was deprecated in v0.2.0 in favor of a global engine object -
Defining the collection with
__collection__
has been removed since it was deprecated in v0.3.0 in favor of thecollection
config option
Deprecations
We comply with the new Pydantic method naming, prefixing them with model_
-
Model.dict
has been deprecated in favor ofModel.model_dump
-
Model.doc
has been deprecated in favor ofModel.model_dump_doc
-
Model.parse_doc
has been deprecated in favor ofModel.model_validate_doc
-
Model.update
has been deprecated in favor ofModel.model_update
-
Model.copy
has been deprecated in favor ofModel.model_copy