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