mirror of
https://github.com/zulip/zulip.git
synced 2025-11-05 06:23:38 +00:00
message_fetch: Replace Select.column() with Select.add_columns().
Fixes “SADeprecationWarning: The Select.column() method is deprecated and will be removed in a future release. Please use Select.add_columns() (deprecated since: 1.4)”. Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
d5a5b0b5ac
commit
8769c0c485
@@ -507,15 +507,13 @@ class NarrowBuilder:
|
|||||||
query_extract_keywords = func.pgroonga_query_extract_keywords
|
query_extract_keywords = func.pgroonga_query_extract_keywords
|
||||||
operand_escaped = func.escape_html(operand, type_=Text)
|
operand_escaped = func.escape_html(operand, type_=Text)
|
||||||
keywords = query_extract_keywords(operand_escaped)
|
keywords = query_extract_keywords(operand_escaped)
|
||||||
query = query.column(
|
query = query.add_columns(
|
||||||
match_positions_character(column("rendered_content", Text), keywords).label(
|
match_positions_character(column("rendered_content", Text), keywords).label(
|
||||||
"content_matches"
|
"content_matches"
|
||||||
)
|
),
|
||||||
)
|
|
||||||
query = query.column(
|
|
||||||
match_positions_character(
|
match_positions_character(
|
||||||
func.escape_html(topic_column_sa(), type_=Text), keywords
|
func.escape_html(topic_column_sa(), type_=Text), keywords
|
||||||
).label("topic_matches")
|
).label("topic_matches"),
|
||||||
)
|
)
|
||||||
condition = column("search_pgroonga", Text).op("&@~")(operand_escaped)
|
condition = column("search_pgroonga", Text).op("&@~")(operand_escaped)
|
||||||
return query.where(maybe_negate(condition))
|
return query.where(maybe_negate(condition))
|
||||||
@@ -524,18 +522,16 @@ class NarrowBuilder:
|
|||||||
self, query: Select, operand: str, maybe_negate: ConditionTransform
|
self, query: Select, operand: str, maybe_negate: ConditionTransform
|
||||||
) -> Select:
|
) -> Select:
|
||||||
tsquery = func.plainto_tsquery(literal("zulip.english_us_search"), literal(operand))
|
tsquery = func.plainto_tsquery(literal("zulip.english_us_search"), literal(operand))
|
||||||
query = query.column(
|
query = query.add_columns(
|
||||||
ts_locs_array(
|
ts_locs_array(
|
||||||
literal("zulip.english_us_search", Text), column("rendered_content", Text), tsquery
|
literal("zulip.english_us_search", Text), column("rendered_content", Text), tsquery
|
||||||
).label("content_matches")
|
).label("content_matches"),
|
||||||
)
|
# We HTML-escape the topic in PostgreSQL to avoid doing a server round-trip
|
||||||
# We HTML-escape the topic in PostgreSQL to avoid doing a server round-trip
|
|
||||||
query = query.column(
|
|
||||||
ts_locs_array(
|
ts_locs_array(
|
||||||
literal("zulip.english_us_search", Text),
|
literal("zulip.english_us_search", Text),
|
||||||
func.escape_html(topic_column_sa(), type_=Text),
|
func.escape_html(topic_column_sa(), type_=Text),
|
||||||
tsquery,
|
tsquery,
|
||||||
).label("topic_matches")
|
).label("topic_matches"),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Do quoted string matching. We really want phrase
|
# Do quoted string matching. We really want phrase
|
||||||
@@ -834,7 +830,7 @@ def add_narrow_conditions(
|
|||||||
|
|
||||||
if search_operands:
|
if search_operands:
|
||||||
is_search = True
|
is_search = True
|
||||||
query = query.column(topic_column_sa()).column(column("rendered_content", Text))
|
query = query.add_columns(topic_column_sa(), column("rendered_content", Text))
|
||||||
search_term = dict(
|
search_term = dict(
|
||||||
operator="search",
|
operator="search",
|
||||||
operand=" ".join(search_operands),
|
operand=" ".join(search_operands),
|
||||||
|
|||||||
Reference in New Issue
Block a user