From c4ab81ebe18ea5fa828eb6663d9bf0fb787946e6 Mon Sep 17 00:00:00 2001 From: "Evgeni (Gene) Makarov" Date: Mon, 26 Oct 2020 19:46:43 +0300 Subject: [PATCH] Uppercase and lowercase string enums behaviour updated. --- src/infi/clickhouse_orm/fields.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/infi/clickhouse_orm/fields.py b/src/infi/clickhouse_orm/fields.py index b63997e..a17aefc 100644 --- a/src/infi/clickhouse_orm/fields.py +++ b/src/infi/clickhouse_orm/fields.py @@ -468,7 +468,10 @@ class BaseEnumField(Field): return value try: if isinstance(value, str): - return self.enum_cls[value] + try: + return self.enum_cls[value] + except Exception: + return self.enum_cls(value) if isinstance(value, bytes): return self.enum_cls[value.decode('UTF-8')] if isinstance(value, int): @@ -665,4 +668,3 @@ class LowCardinalityField(Field): # Expose only relevant classes in import * __all__ = get_subclass_names(locals(), Field) -