Skip to content

Commit

Permalink
database:column - better handling of enum types
Browse files Browse the repository at this point in the history
  • Loading branch information
MatteoCampinoti94 committed Nov 2, 2023
1 parent 65d2f8a commit 5aa7db2
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions acacore/database/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 5aa7db2

Please sign in to comment.