Releases: art049/odmantic
v1.0.2
v1.0.1
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 aNoneimplicit default value anymore -
Model.copydoesn't support theexcludeandincludekwargs anymore -
odmantic.Fielddoesn't accept extra kwargs anymore since it's slated to be removed in Pydantic -
The
Configclass is no longer supported and themodel_configdict should be used instead -
DocumentParsingErroris 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 theWithBSONSerializerannotation. -
Decimals (
decimal.Decimalandbson.Decimal128) are now serialized as strings in JSON documents -
Custom JSON encoders(defined with the
json_encodersconfig option) are no longer effective onodmantic.bsontypes. Annotated types withpydantic.PlainSerializershould be used instead.
Removals
-
AIOEngineDependencyhas 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 thecollectionconfig option
Deprecations
We comply with the new Pydantic method naming, prefixing them with model_
-
Model.dicthas been deprecated in favor ofModel.model_dump -
Model.dochas been deprecated in favor ofModel.model_dump_doc -
Model.parse_dochas been deprecated in favor ofModel.model_validate_doc -
Model.updatehas been deprecated in favor ofModel.model_update -
Model.copyhas been deprecated in favor ofModel.model_copy
Details
v0.9.2
v0.9.1
v0.9.0
Added
-
Create new generic types to support generic collection types (#240 by @erny & @art049)
Thus, it's now possible to define models like this in python 3.9+ 🚀:
class User(Model): scopes: list[str] friendsIds: list[ObjectId] skills: set[str]
-
Allow using generators with
in_andnot_in(#270 by @art049)
Fixed
v0.8.0
Added
-
Allow Index definition (feature documentation) (#255 by @art049)
-
Allow using the
Config.extraattribute from pydantic (#259 by @art049)
Fixed
v0.7.1
v0.7.0
Added
-
Add new SyncEngine, support async and sync code (#231 by @tiangolo)
-
Friendly interface for session and transaction management (documentation) (#244 by @art049)
-
Implement the
engine.removemethod to allow instance deletion from a query (#147 & #237 by @joeriddles & @art049)
Internals
v0.6.0
Breaking Changes
Added
-
Upgrade types and add support for instance autocompletion with
dataclass_transform(VS Code autocompletion) (#230 by @tiangolo)
Fixed
-
Fix using the shared session when updating a document (#227 by @tiangolo)
-
Allow models to contain string-based datetime fields that indicate UTC (#136 by @kfox)
-
Fix
Referenceusage with non the non default primary key (#184 by @dynalz) -
Fix
key_nameuse on EmbeddedModels (#195 by @jvanegmond)