added distinct when outer joining for user filters (#3641)

* added distinct when outer joining for user filters

* Added distinct when outer joining for user filters for all
This commit is contained in:
hagen-danswer 2025-01-09 14:15:38 -08:00 committed by GitHub
parent 2ae91f0f2b
commit c55de28423
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 6 additions and 0 deletions

View File

@ -24,6 +24,7 @@ def _add_user_filters(
if user is None or user.role == UserRole.ADMIN:
return stmt
stmt = stmt.distinct()
TRLimit_UG = aliased(TokenRateLimit__UserGroup)
User__UG = aliased(User__UserGroup)

View File

@ -39,6 +39,7 @@ def _add_user_filters(
if user is None or user.role == UserRole.ADMIN:
return stmt
stmt = stmt.distinct()
UG__CCpair = aliased(UserGroup__ConnectorCredentialPair)
User__UG = aliased(User__UserGroup)

View File

@ -74,6 +74,7 @@ def _add_user_filters(
# Basic users can only access credentials that are owned by them
return stmt.where(Credential.user_id == user.id)
stmt = stmt.distinct()
"""
THIS PART IS FOR CURATORS AND GLOBAL CURATORS
Here we select cc_pairs by relation:

View File

@ -40,6 +40,7 @@ def _add_user_filters(
if user is None or user.role == UserRole.ADMIN:
return stmt
stmt = stmt.distinct()
DocumentSet__UG = aliased(DocumentSet__UserGroup)
User__UG = aliased(User__UserGroup)
"""

View File

@ -50,6 +50,7 @@ def _add_user_filters(
if user is None or user.role == UserRole.ADMIN:
return stmt
stmt = stmt.distinct()
DocByCC = aliased(DocumentByConnectorCredentialPair)
CCPair = aliased(ConnectorCredentialPair)
UG__CCpair = aliased(UserGroup__ConnectorCredentialPair)

View File

@ -49,6 +49,7 @@ def _add_user_filters(
if user is None or user.role == UserRole.ADMIN:
return stmt
stmt = stmt.distinct()
Persona__UG = aliased(Persona__UserGroup)
User__UG = aliased(User__UserGroup)
"""