awtkns / fastapi-crudrouter

A dynamic FastAPI router that automatically creates CRUD routes for your models
https://fastapi-crudrouter.awtkns.com
MIT License
1.38k stars 155 forks source link

All ORMs/backends should allow partial updates #168

Open ulasozguler opened 2 years ago

ulasozguler commented 2 years ago

Currently, only tortoise and ormar backends are allowing partial updates. See relevant line for tortoise below.

https://github.com/awtkns/fastapi-crudrouter/blob/66fd32fafaf191c58c388eb8a849dddef6e569a4/fastapi_crudrouter/core/tortoise.py#L95

Behaviour should be consistent across all backends when possible.

Requirement of fields should be determined by pydantic model as its primary function is validation. Currently, marking a field of pydantic model as Optional or setting a default value doesn't allow skipping that field when sending a request (for backends other than tortoise and ormar).

Making this change would allow to both keeping the current behaviour and enabling partial updates depending on your pydantic model.

I can create a pull request for this if it gets approved. I have already tested it in my local environment and doesn't seem to break anything else.