diff --git a/app/db/repository/user.py b/app/db/repository/user.py index d1ad2ec..78d8878 100644 --- a/app/db/repository/user.py +++ b/app/db/repository/user.py @@ -131,7 +131,10 @@ def delete_user_data(id: int, db: Session): def user_search_query( db: Session, name: str = "", role: str = None, page: int = 1, per_page: int = 20 ): - query = db.query(User).filter(User.Name.like(f"{name}%")) + if name == "" or name is None: + query = db.query(User) + else: + query = db.query(User).filter(User.Name.like(f"{name}%")) if role is not None and role != "Admin": query = query.filter(User.Role == role) total_users = query.count()