Adding some documentation to the helper function.

Signed-off-by: Cliff Hill <Clifford.hill@gsa.gov>
This commit is contained in:
Cliff Hill
2024-01-18 09:46:43 -05:00
parent f4c8c3e743
commit 655a57c0a4

View File

@@ -53,7 +53,20 @@ def filter_null_value_fields(obj):
def enum_values(enum_type):
"""Helper function used to persist enum values to the database rather than names."""
"""
Helper function used to persist enum values to the database rather than names.
See Also:
https://docs.sqlalchemy.org/en/14/core/type_basics.html#sqlalchemy.types.Enum
Notes:
In order to persist the values and not the names, the Enum.values_callable
parameter may be used. The value of this parameter is a user-supplied callable,
which is intended to be used with a PEP-435-compliant enumerated class and
returns a list of string values to be persisted. For a simple enumeration that
uses string values, a callable such as lambda x: [e.value for e in x] is
sufficient.
"""
return [i.value for i in enum_type]