@@ -239,7 +239,6 @@ class MessageSearchTest(HomeserverTestCase):
239
239
("fox -nope" , (True , False )),
240
240
("fox -brown" , (False , True )),
241
241
('"fox" quick' , True ),
242
- ('"fox quick' , True ),
243
242
('"quick brown' , True ),
244
243
('" quick "' , True ),
245
244
('" nope"' , False ),
@@ -269,6 +268,15 @@ def prepare(
269
268
response = self .helper .send (self .room_id , self .PHRASE , tok = self .access_token )
270
269
self .assertIn ("event_id" , response )
271
270
271
+ # The behaviour of a missing trailing double quote changed in PostgreSQL 14
272
+ # from ignoring the initial double quote to treating it as a phrase.
273
+ main_store = homeserver .get_datastores ().main
274
+ found = False
275
+ if isinstance (main_store .database_engine , PostgresEngine ):
276
+ assert main_store .database_engine ._version is not None
277
+ found = main_store .database_engine ._version < 140000
278
+ self .COMMON_CASES .append (('"fox quick' , (found , True )))
279
+
272
280
def test_tokenize_query (self ) -> None :
273
281
"""Test the custom logic to tokenize a user's query."""
274
282
cases = (
@@ -280,9 +288,9 @@ def test_tokenize_query(self) -> None:
280
288
("fox -brown" , ["fox" , SearchToken .Not , "brown" ]),
281
289
("- fox" , [SearchToken .Not , "fox" ]),
282
290
('"fox" quick' , [Phrase (["fox" ]), SearchToken .And , "quick" ]),
283
- # No trailing double quoe .
284
- ('"fox quick' , ["fox" , SearchToken . And , "quick" ]),
285
- ('"-fox quick' , [SearchToken . Not , " fox" , SearchToken . And , "quick" ]),
291
+ # No trailing double quote .
292
+ ('"fox quick' , [Phrase ([ "fox" , "quick" ]) ]),
293
+ ('"-fox quick' , [Phrase ([ "- fox" , "quick" ]) ]),
286
294
('" quick "' , [Phrase (["quick" ])]),
287
295
(
288
296
'q"uick brow"n' ,
0 commit comments