From ffeadeea51ba1d320871f2c27765e15d8d765b66 Mon Sep 17 00:00:00 2001 From: BryantHe Date: Tue, 27 Jun 2023 03:11:22 +0800 Subject: [PATCH] fix db_model bug --- chassis/db_model.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/chassis/db_model.py b/chassis/db_model.py index a03294a..08cf958 100644 --- a/chassis/db_model.py +++ b/chassis/db_model.py @@ -26,10 +26,11 @@ class BaseCrud(BaseModel): @classmethod def filtered_query(cls, session, filter_args=None, filter_kwargs=None) -> Query: - if filter_args: - return session.query(cls).filter(*filter_args).filter_by(**filter_kwargs) - else: - return session.query(cls).filter().filter_by(**filter_kwargs) + if not filter_args: + filter_args = [] + if not filter_kwargs: + filter_kwargs = {} + return session.query(cls).filter(*filter_args).filter_by(**filter_kwargs) # 增 @classmethod @@ -90,10 +91,11 @@ class InfoCrud(BaseModel): @classmethod def filtered_query(cls, session, filter_args=None, filter_kwargs=None) -> Query: - if filter_args: - return session.query(cls).filter(*filter_args).filter_by(**filter_kwargs) - else: - return session.query(cls).filter().filter_by(**filter_kwargs) + if not filter_args: + filter_args = [] + if not filter_kwargs: + filter_kwargs = {} + return session.query(cls).filter(*filter_args).filter_by(**filter_kwargs) # 增 @classmethod