odmantic
odmantic copied to clipboard
Support `pydantic.BaseModel.Config.underscore_attrs_are_private`
Feature request
Support using the underscore_attrs_are_private
config in models.
Context
I use pydantic's underscore_attrs_are_private
feature to have field in my pydantic models that are are not public.
from odmantic import Model
class Example(Model)
class Config:
underscore_attrs_are_private = True
odmantic.config.py
raises ValueError: 'Example': 'Config.underscore_attrs_are_private' is not supported
Solution
Be able to use <model>.Config.underscore_attrs_are_private
without an error being raised.
Alternative solutions
None.
Additional context
None.
Hi, What kind of behavior would you expect from those attributes ? Should they be persisted in the database ? or ignored ? If you have also a concrete example it would help me to understand the need as well
I'd like to see this too. My expectation is that private attributes wouldn't be persisted in the DB at all. In my use case, this would make sense as we have objects that persist and may be read, but those objects also have transient/runtime attributes which don't need to be saved/read.