fix db filtering
This commit is contained in:
@@ -237,7 +237,7 @@ class BotEntity[CreateSchemaType: BaseModel, UpdateSchemaType: BaseModel](
|
||||
cls, select_statement: SelectOfScalar[Self], static_filter: list[Filter]
|
||||
):
|
||||
for sfilt in static_filter:
|
||||
column = col(getattr(cls, sfilt.field_name))
|
||||
column = getattr(cls, sfilt.field_name)
|
||||
if sfilt.operator == "==":
|
||||
condition = column.__eq__(sfilt.value)
|
||||
elif sfilt.operator == "!=":
|
||||
@@ -251,19 +251,19 @@ class BotEntity[CreateSchemaType: BaseModel, UpdateSchemaType: BaseModel](
|
||||
elif sfilt.operator == ">=":
|
||||
condition = column.__ge__(sfilt.value)
|
||||
elif sfilt.operator == "ilike":
|
||||
condition = column.ilike(f"%{sfilt.value}%")
|
||||
condition = col(column).ilike(f"%{sfilt.value}%")
|
||||
elif sfilt.operator == "like":
|
||||
condition = column.like(f"%{sfilt.value}%")
|
||||
condition = col(column).like(f"%{sfilt.value}%")
|
||||
elif sfilt.operator == "in":
|
||||
condition = column.in_(sfilt.value)
|
||||
condition = col(column).in_(sfilt.value)
|
||||
elif sfilt.operator == "not in":
|
||||
condition = column.notin_(sfilt.value)
|
||||
condition = col(column).notin_(sfilt.value)
|
||||
elif sfilt.operator == "is none":
|
||||
condition = column.is_(None)
|
||||
condition = col(column).is_(None)
|
||||
elif sfilt.operator == "is not none":
|
||||
condition = column.isnot(None)
|
||||
condition = col(column).isnot(None)
|
||||
elif sfilt.operator == "contains":
|
||||
condition = sfilt.value == column.any_()
|
||||
condition = sfilt.value == col(column).any_()
|
||||
else:
|
||||
condition = None
|
||||
if condition is not None:
|
||||
|
||||
@@ -166,7 +166,7 @@ class EnumType(TypeDecorator):
|
||||
def process_bind_param(self, value, dialect):
|
||||
if value and isinstance(value, EnumMember):
|
||||
return value.value
|
||||
return None
|
||||
return str(value)
|
||||
|
||||
def process_result_value(self, value, dialect):
|
||||
if value:
|
||||
|
||||
Reference in New Issue
Block a user