From ca57a223ca2bc17b23423d28d5424ace7492dc01 Mon Sep 17 00:00:00 2001 From: Alexander Goldberg Date: Mon, 7 Dec 2020 19:05:49 +0200 Subject: [PATCH] Revert "Uppercase and lowercase string enums behaviour updated." --- src/infi/clickhouse_orm/fields.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/infi/clickhouse_orm/fields.py b/src/infi/clickhouse_orm/fields.py index 4f631cc..b63997e 100644 --- a/src/infi/clickhouse_orm/fields.py +++ b/src/infi/clickhouse_orm/fields.py @@ -468,16 +468,9 @@ class BaseEnumField(Field): return value try: if isinstance(value, str): - try: - return self.enum_cls[value] - except Exception: - return self.enum_cls(value) + return self.enum_cls[value] if isinstance(value, bytes): - decoded = value.decode('UTF-8') - try: - return self.enum_cls[decoded] - except Exception: - return self.enum_cls(decoded) + return self.enum_cls[value.decode('UTF-8')] if isinstance(value, int): return self.enum_cls(value) except (KeyError, ValueError): @@ -672,3 +665,4 @@ class LowCardinalityField(Field): # Expose only relevant classes in import * __all__ = get_subclass_names(locals(), Field) +