From d6cfee3ca021262b76a36ee4b5f5888aa69e1230 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=BD=E5=A5=87=E5=AE=9D=E5=AE=9D?= <11259906+haoqibb@user.noreply.gitee.com> Date: Wed, 20 Aug 2025 07:19:34 +0000 Subject: [PATCH] =?UTF-8?q?update=20backend/app/core/base=5Fcrud.py.=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6=E6=AF=94?= =?UTF-8?q?=E8=BE=83=E8=BF=90=E7=AE=97=E7=AC=A6=E8=BD=AC=E6=8D=A2=E4=B8=8D?= =?UTF-8?q?=E5=AE=8C=E6=95=B4=E5=AF=BC=E8=87=B4InstrumentedAttribute?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 好奇宝宝 <11259906+haoqibb@user.noreply.gitee.com> --- backend/app/core/base_crud.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/app/core/base_crud.py b/backend/app/core/base_crud.py index 742ecd9..c870019 100644 --- a/backend/app/core/base_crud.py +++ b/backend/app/core/base_crud.py @@ -338,7 +338,13 @@ class CRUDBase(Generic[ModelType, CreateSchemaType, UpdateSchemaType]): elif seq == "!=" and val: conditions.append(attr != val) elif seq in [">", ">=", "<=", "=="] and val: - conditions.append(getattr(attr, seq.replace("==", "__eq__"))(val)) + op_map = { + ">": "__gt__", + ">=": "__ge__", + "<=": "__le__", + "==": "__eq__" + } + conditions.append(getattr(attr, op_map[seq])(val)) else: conditions.append(attr == value) return conditions -- Gitee