Skip to content

Commit

Permalink
Use the IS operator in SQL instead of equality for boolean comparisons.
Browse files Browse the repository at this point in the history
  • Loading branch information
bakar-io committed Apr 26, 2024
1 parent 5b47304 commit 4ba6635
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions backend/app/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ async def get_assistant(user_id: str, assistant_id: str) -> Optional[Assistant]:
"""Get an assistant by ID."""
async with get_pg_pool().acquire() as conn:
return await conn.fetchrow(
"SELECT * FROM assistant WHERE assistant_id = $1 AND (user_id = $2 OR public = true)",
"SELECT * FROM assistant WHERE assistant_id = $1 AND (user_id = $2 OR public IS true)",
assistant_id,
user_id,
)
Expand All @@ -28,7 +28,7 @@ async def get_assistant(user_id: str, assistant_id: str) -> Optional[Assistant]:
async def list_public_assistants() -> List[Assistant]:
"""List all the public assistants."""
async with get_pg_pool().acquire() as conn:
return await conn.fetch(("SELECT * FROM assistant WHERE public = true;"))
return await conn.fetch(("SELECT * FROM assistant WHERE public IS true;"))


async def put_assistant(
Expand Down

0 comments on commit 4ba6635

Please sign in to comment.