changes reverted after rebase

This commit is contained in:
Evgeni (Gene) Makarov 2020-12-14 14:39:36 +03:00
parent 97f776792f
commit a8ab206849

View File

@ -468,9 +468,16 @@ 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')]
decoded = value.decode('UTF-8')
try:
return self.enum_cls[decoded]
except Exception:
return self.enum_cls(decoded)
if isinstance(value, int):
return self.enum_cls(value)
except (KeyError, ValueError):
@ -665,4 +672,3 @@ class LowCardinalityField(Field):
# Expose only relevant classes in import *
__all__ = get_subclass_names(locals(), Field)