You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, any optional field name that starts with _ is not stored in the database. Which makes implementing the getter/setter pattern a nuisance.
class User(JsonModel):
public_attribute: str = Field(index=True) # will be stored
_private_attribute : typing.Optional[str] = Field(index=True) # will NOT be stored
Is there any workaround for this implementation?
The text was updated successfully, but these errors were encountered:
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?
The text was updated successfully, but these errors were encountered: