fix BotEnum comparison

This commit is contained in:
Alexander Kalinovsky
2025-02-09 23:13:39 +01:00
parent 7a4936d2ef
commit a0f21e0f1b
2 changed files with 7 additions and 4 deletions

View File

@@ -338,7 +338,7 @@ class BotEntity[CreateSchemaType: BaseModel, UpdateSchemaType: BaseModel](
select_statement = select(cls).offset(skip) select_statement = select(cls).offset(skip)
if limit: if limit:
select_statement = select_statement.limit(limit) select_statement = select_statement.limit(limit)
if static_filter: if static_filter is not None:
if isinstance(static_filter, list): if isinstance(static_filter, list):
select_statement = cls._static_filter_condition( select_statement = cls._static_filter_condition(
select_statement, static_filter select_statement, static_filter
@@ -349,11 +349,11 @@ class BotEntity[CreateSchemaType: BaseModel, UpdateSchemaType: BaseModel](
select_statement = cls._filter_condition( select_statement = cls._filter_condition(
select_statement, filter, filter_fields select_statement, filter, filter_fields
) )
if ext_filter: if ext_filter is not None:
select_statement = select_statement.where(ext_filter) select_statement = select_statement.where(ext_filter)
if user: if user:
select_statement = cls._ownership_condition(select_statement, user) select_statement = cls._ownership_condition(select_statement, user)
if order_by: if order_by is not None:
select_statement = select_statement.order_by(order_by) select_statement = select_statement.order_by(order_by)
return (await session.exec(select_statement)).all() return (await session.exec(select_statement)).all()

View File

@@ -126,7 +126,10 @@ class EnumMember(object):
if isinstance(other, str): if isinstance(other, str):
return self.value == other return self.value == other
if isinstance(other, EnumMember): if isinstance(other, EnumMember):
return self.value == other.value and self._parent is other._parent return self.value == other.value and (
issubclass(self._parent, other._parent)
or issubclass(other._parent, self._parent)
)
return other.__eq__(self.value) return other.__eq__(self.value)
def __hash__(self): def __hash__(self):