From 5aa7db27050f28ec07991fb746541db00ec44f1e Mon Sep 17 00:00:00 2001 From: Matteo Campinoti Date: Thu, 2 Nov 2023 13:29:42 +0100 Subject: [PATCH] database:column - better handling of enum types --- acacore/database/column.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acacore/database/column.py b/acacore/database/column.py index a92efcb..11e6871 100644 --- a/acacore/database/column.py +++ b/acacore/database/column.py @@ -70,8 +70,8 @@ def _schema_to_column(name: str, schema: dict, defs: Optional[dict[str, dict]] = sql_type = _sql_schema_types.get(schema_type, None) type_name: str = schema.get("format", schema_type) - if schema.get("enum"): - to_entry, from_entry = lambda e: e.value, str + if schema.get("enum") is not None: + to_entry, from_entry = schema["enum"][0].__class__ if schema["enum"] else str, str elif schema_type in ("object", "array"): sql_type = "text" to_entry, from_entry = lambda o: dumps(dump_object(o), default=str), lambda o: loads(o)