From 655a57c0a4e926befca2017b138d9b802e0bdc0b Mon Sep 17 00:00:00 2001 From: Cliff Hill Date: Thu, 18 Jan 2024 09:46:43 -0500 Subject: [PATCH] Adding some documentation to the helper function. Signed-off-by: Cliff Hill --- app/models.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models.py b/app/models.py index 78307cf85..97043908b 100644 --- a/app/models.py +++ b/app/models.py @@ -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]