Skip to content

Commit fc4e828

Browse files
committed
Make EnumValue support comparison to strings
1 parent 369b18e commit fc4e828

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

gel/datatypes/enum.pyx

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,29 +34,29 @@ class EnumValue(enum.Enum):
3434
elif isinstance(value, enum.Enum):
3535
return cls(value.value)
3636
else:
37-
raise TypeError
37+
return None
3838

3939
def __lt__(self, other):
4040
other = self._try_from(other)
41-
if self.__tid__ != other.__tid__:
41+
if not other or self.__tid__ != other.__tid__:
4242
return NotImplemented
4343
return self._index_ < other._index_
4444

4545
def __gt__(self, other):
4646
other = self._try_from(other)
47-
if self.__tid__ != other.__tid__:
47+
if not other or self.__tid__ != other.__tid__:
4848
return NotImplemented
4949
return self._index_ > other._index_
5050

5151
def __le__(self, other):
5252
other = self._try_from(other)
53-
if self.__tid__ != other.__tid__:
53+
if not other or self.__tid__ != other.__tid__:
5454
return NotImplemented
5555
return self._index_ <= other._index_
5656

5757
def __ge__(self, other):
5858
other = self._try_from(other)
59-
if self.__tid__ != other.__tid__:
59+
if not other or self.__tid__ != other.__tid__:
6060
return NotImplemented
6161
return self._index_ >= other._index_
6262

tests/test_sync_query.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -970,7 +970,7 @@ def test_sync_prefer_rr_01(self):
970970
level := sys::get_transaction_isolation(),
971971
}
972972
''')
973-
self.assertEqual(str(res.level), 'RepeatableRead')
973+
self.assertEqual(res.level, 'RepeatableRead')
974974

975975
# This one can't
976976
res = db2.query_single('''

0 commit comments

Comments
 (0)