mirror of
https://git.anonymousland.org/anonymousland/synapse-product.git
synced 2024-10-01 08:25:44 -04:00
Add SQLite support
This commit is contained in:
parent
f9340ea0d5
commit
cfd39d6b55
@ -17,6 +17,7 @@ from twisted.internet import defer
|
|||||||
|
|
||||||
from _base import SQLBaseStore
|
from _base import SQLBaseStore
|
||||||
from synapse.api.constants import KnownRoomEventKeys, SearchConstraintTypes
|
from synapse.api.constants import KnownRoomEventKeys, SearchConstraintTypes
|
||||||
|
from synapse.storage.engines import PostgresEngine
|
||||||
|
|
||||||
|
|
||||||
class SearchStore(SQLBaseStore):
|
class SearchStore(SQLBaseStore):
|
||||||
@ -48,11 +49,17 @@ class SearchStore(SQLBaseStore):
|
|||||||
"(%s)" % (" OR ".join(local_clauses),)
|
"(%s)" % (" OR ".join(local_clauses),)
|
||||||
)
|
)
|
||||||
|
|
||||||
sql = (
|
if isinstance(self.database_engine, PostgresEngine):
|
||||||
"SELECT ts_rank_cd(vector, query) AS rank, event_id"
|
sql = (
|
||||||
" FROM plainto_tsquery('english', ?) as query, event_search"
|
"SELECT ts_rank_cd(vector, query) AS rank, event_id"
|
||||||
" WHERE vector @@ query"
|
" FROM plainto_tsquery('english', ?) as query, event_search"
|
||||||
)
|
" WHERE vector @@ query"
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
sql = (
|
||||||
|
"SELECT 0 as rank, event_id FROM event_search"
|
||||||
|
" WHERE value MATCH ?"
|
||||||
|
)
|
||||||
|
|
||||||
for clause in clauses:
|
for clause in clauses:
|
||||||
sql += " AND " + clause
|
sql += " AND " + clause
|
||||||
|
Loading…
Reference in New Issue
Block a user