Skip to content

Commit

Permalink
Fixed warning: SAWarning: Coercing Subquery object into a select() fo…
Browse files Browse the repository at this point in the history
…r use in IN()
  • Loading branch information
mjagkow authored and andreaskoepf committed Dec 29, 2022
1 parent 65dbb9c commit acfcd7b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/oasst_backend/prompt_repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ def fetch_random_thread(self, require_role: str = None) -> list[Post]:
distinct_threads = distinct_threads.filter(Post.role == require_role)
distinct_threads = distinct_threads.subquery()

random_thread = self.db.query(distinct_threads).order_by(func.random()).limit(1).subquery()
random_thread = self.db.query(distinct_threads).order_by(func.random()).limit(1)
thread_posts = self.db.query(Post).filter(Post.thread_id.in_(random_thread)).all()
return thread_posts

Expand Down Expand Up @@ -443,7 +443,7 @@ def fetch_multiple_random_replies(self, max_size: int = 5, post_role: str = None
if post_role:
parent = parent.filter(Post.role == post_role)

parent = parent.order_by(func.random()).limit(1).subquery()
parent = parent.order_by(func.random()).limit(1)
replies = self.db.query(Post).filter(Post.parent_id.in_(parent)).order_by(func.random()).limit(max_size).all()
if not replies:
raise OasstError("No replies found", OasstErrorCode.NO_REPLIES_FOUND)
Expand Down

0 comments on commit acfcd7b

Please sign in to comment.