Closed zidokobik closed 2 months ago
seems this is a Pydantic thing via the private model attributes
IMO this is the correct behavior, so no I don't think there is a workaround (nor would one be appropriate).
This goes back to OOP, if you declare a field as a private you are saying you only want the class itself to be responsible for mutating the field. There are conventions in other languages (e.g. Java) to allow setters and getters when you want things like serializers to have access to the field, but this is python so the most correct way to manage this would be for the field to not be private.
Currently, any optional field name that starts with
_
is not stored in the database. Which makes implementing the getter/setter pattern a nuisance.Is there any workaround for this implementation?