-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Fix tests for change in PostgreSQL 14 behavior change. #14310
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Allow use of postgres and sqllite full-text search operators in search queries. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -239,7 +239,6 @@ class MessageSearchTest(HomeserverTestCase): | |
("fox -nope", (True, False)), | ||
("fox -brown", (False, True)), | ||
('"fox" quick', True), | ||
('"fox quick', True), | ||
('"quick brown', True), | ||
('" quick "', True), | ||
('" nope"', False), | ||
|
@@ -269,6 +268,14 @@ def prepare( | |
response = self.helper.send(self.room_id, self.PHRASE, tok=self.access_token) | ||
self.assertIn("event_id", response) | ||
|
||
# The behaviour of a missing trailing double quote changed in PostgreSQL 14 | ||
# from ignoring the initial double quote to treating it as a phrase. | ||
Comment on lines
+271
to
+272
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To check: we've changed our parser to mirror this behaviour? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, so SQLite will match the behavior of PostgreSQL 14. PostgreSQL 11 - 13 will still use whatever their internal function call does. (And PostgreSQL 10 fallsback to |
||
main_store = homeserver.get_datastores().main | ||
found = False | ||
if isinstance(main_store.database_engine, PostgresEngine): | ||
found = main_store.database_engine._version < 140000 | ||
self.COMMON_CASES.append(('"fox quick', (found, True))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To check: I think this means that:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not really, what it means is that:
|
||
|
||
def test_tokenize_query(self) -> None: | ||
"""Test the custom logic to tokenize a user's query.""" | ||
cases = ( | ||
|
@@ -280,9 +287,9 @@ def test_tokenize_query(self) -> None: | |
("fox -brown", ["fox", SearchToken.Not, "brown"]), | ||
("- fox", [SearchToken.Not, "fox"]), | ||
('"fox" quick', [Phrase(["fox"]), SearchToken.And, "quick"]), | ||
# No trailing double quoe. | ||
('"fox quick', ["fox", SearchToken.And, "quick"]), | ||
('"-fox quick', [SearchToken.Not, "fox", SearchToken.And, "quick"]), | ||
# No trailing double quote. | ||
('"fox quick', [Phrase(["fox", "quick"])]), | ||
('"-fox quick', [Phrase(["-fox", "quick"])]), | ||
('" quick "', [Phrase(["quick"])]), | ||
( | ||
'q"uick brow"n', | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To check: this means that a trailing quote is now implied?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. 👍