v10.0.0 #976
Replies: 2 comments 1 reply
-
I am very excited to try this out, I have a terrible subclass of Thank you! |
Beta Was this translation helpful? Give feedback.
-
Sad to see I think more work on the |
Beta Was this translation helpful? Give feedback.
-
Breaking changes
Version 10 marks important changes in how we manage User models and their ID.
Before, we were relying only on Pydantic models to work with users. In particular the
current_user
dependency would return you an instance ofUserDB
, a Pydantic model. This proved to be quite problematic with some ORM if you ever needed to retrieve relationship data or make specific requests.Now, FastAPI Users is designed to always return you a native object for your ORM model, whether it's an SQLAlchemy model or a Beanie document. Pydantic models are now only used for validation and serialization inside the API.
Before, we were forcing the use of UUID as primary key ID; a consequence of the design above. This proved to be quite problematic on some databases, like MongoDB which uses a special ObjectID format by default. Some SQL folks also prefer to use traditional auto-increment integers.
Now, FastAPI Users is designed to use generic ID type. It means that you can use any type you want for your user's ID. By default, SQLAlchemy adapter still use UUID; but you can quite easily switch to another thing, like an integer. Beanie adapter for MongoDB will use native ObjectID by default, but it also can be overriden.
READ THE MIGRATION PATH
Documentation improvements
This discussion was created from the release v10.0.0.
Beta Was this translation helpful? Give feedback.
All reactions