From 80e2d4d4ee8388d5ea0c4231f711848d2e9389f0 Mon Sep 17 00:00:00 2001 From: Peter De-Ath Date: Sun, 17 Nov 2024 19:53:51 +0000 Subject: [PATCH] fix: user ID filtering in GroupTable query --- backend/open_webui/apps/webui/models/groups.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/apps/webui/models/groups.py b/backend/open_webui/apps/webui/models/groups.py index e687374ea..3795466bc 100644 --- a/backend/open_webui/apps/webui/models/groups.py +++ b/backend/open_webui/apps/webui/models/groups.py @@ -11,7 +11,7 @@ from open_webui.apps.webui.models.files import FileMetadataResponse from pydantic import BaseModel, ConfigDict -from sqlalchemy import BigInteger, Column, String, Text, JSON +from sqlalchemy import BigInteger, Column, String, Text, JSON, func log = logging.getLogger(__name__) @@ -128,7 +128,8 @@ class GroupTable: return [ GroupModel.model_validate(group) for group in db.query(Group) - .filter(Group.user_ids.contains([user_id])) + .filter(func.json_array_length(Group.user_ids) > 0) # Ensure array exists + .filter(Group.user_ids.cast(String).like(f'%"{user_id}"%')) # String-based check .order_by(Group.updated_at.desc()) .all() ]