From cd9397bfa15fe75148b7a6ecd760aa0a7441e2cc Mon Sep 17 00:00:00 2001 From: Madiwka Date: Sat, 18 Nov 2023 12:14:22 +0600 Subject: [PATCH] Fixed user search --- app/db/repository/user.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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()