narrow: Migrate legacy SQLAlchemy select syntax.

Fixes “sqlalchemy.exc.RemovedIn20Warning: Deprecated API features
detected! These feature(s) are not compatible with SQLAlchemy 2.0.”
with warnings enabled.

https://docs.sqlalchemy.org/en/14/changelog/migration_14.html#change-5284

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2024-07-16 13:48:35 -07:00 committed by Tim Abbott
parent 8682ea1a64
commit dd0d482d76
2 changed files with 2 additions and 2 deletions

View File

@ -354,7 +354,7 @@ class NarrowBuilder:
# If the initial query doesn't use `zerver_usermessage` # If the initial query doesn't use `zerver_usermessage`
check_col = literal_column("zerver_message.id", Integer) check_col = literal_column("zerver_message.id", Integer)
exists_cond = ( exists_cond = (
select([1]) select(1)
.select_from(table("zerver_reaction")) .select_from(table("zerver_reaction"))
.where(check_col == literal_column("zerver_reaction.message_id", Integer)) .where(check_col == literal_column("zerver_reaction.message_id", Integer))
.exists() .exists()

View File

@ -23,7 +23,7 @@ def topic_column_sa() -> ColumnElement[Text]:
def get_followed_topic_condition_sa(user_id: int) -> ColumnElement[Boolean]: def get_followed_topic_condition_sa(user_id: int) -> ColumnElement[Boolean]:
follow_topic_cond = ( follow_topic_cond = (
select([1]) select(1)
.select_from(table("zerver_usertopic")) .select_from(table("zerver_usertopic"))
.where( .where(
and_( and_(