Skip to content

Commit

Permalink
added distinct when outer joining for user filters (#3641)
Browse files Browse the repository at this point in the history
* added distinct when outer joining for user filters

* Added distinct when outer joining for user filters for all
  • Loading branch information
hagen-danswer authored Jan 9, 2025
1 parent 2ae91f0 commit c55de28
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions backend/ee/onyx/db/token_limit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions backend/onyx/db/connector_credential_pair.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions backend/onyx/db/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions backend/onyx/db/document_set.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"""
Expand Down
1 change: 1 addition & 0 deletions backend/onyx/db/feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions backend/onyx/db/persona.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
"""
Expand Down

0 comments on commit c55de28

Please sign in to comment.