odmantic icon indicating copy to clipboard operation
odmantic copied to clipboard

Support `pydantic.BaseModel.Config.underscore_attrs_are_private`

Open joeriddles opened this issue 3 years ago • 2 comments

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.

joeriddles avatar Jun 25 '21 20:06 joeriddles

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

art049 avatar Jul 05 '21 13:07 art049

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.

austin1howard avatar Aug 25 '21 19:08 austin1howard