mirror of
https://github.com/Infinidat/infi.clickhouse_orm.git
synced 2024-11-22 00:56:34 +03:00
Merge pull request #161 from emakarov/case_sensitive_strenums
Uppercase and lowercase string enums behaviour updated
This commit is contained in:
commit
7c90c1e4c3
|
@ -468,9 +468,16 @@ class BaseEnumField(Field):
|
||||||
return value
|
return value
|
||||||
try:
|
try:
|
||||||
if isinstance(value, str):
|
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):
|
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):
|
if isinstance(value, int):
|
||||||
return self.enum_cls(value)
|
return self.enum_cls(value)
|
||||||
except (KeyError, ValueError):
|
except (KeyError, ValueError):
|
||||||
|
@ -665,4 +672,3 @@ class LowCardinalityField(Field):
|
||||||
|
|
||||||
# Expose only relevant classes in import *
|
# Expose only relevant classes in import *
|
||||||
__all__ = get_subclass_names(locals(), Field)
|
__all__ = get_subclass_names(locals(), Field)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user