This repository was archived by the owner on Apr 26, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +18
-7
lines changed
Expand file tree Collapse file tree 5 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -477,14 +477,11 @@ async def delete_messages_for_device(
477477 log_kv ({"message" : "No changes in cache since last check" })
478478 return 0
479479
480- ROW_ID_LITERAL = "ctid" if isinstance (self .database_engine , PostgresEngine ) else "rowid"
481-
482480 def delete_messages_for_device_txn (txn : LoggingTransaction ) -> int :
483481 sql = (
484- f"DELETE FROM device_inbox WHERE { ROW_ID_LITERAL } IN ("
485- f"SELECT { ROW_ID_LITERAL } FROM device_inbox"
486- " WHERE user_id = ? AND device_id = ?"
487- " AND stream_id <= ?"
482+ f"DELETE FROM device_inbox WHERE { self .database_engine .row_id_name } IN ("
483+ f"SELECT { self .database_engine .row_id_name } FROM device_inbox"
484+ " WHERE user_id = ? AND device_id = ? AND stream_id <= ?"
488485 )
489486 if limit :
490487 sql += f" LIMIT { limit } "
Original file line number Diff line number Diff line change @@ -100,6 +100,12 @@ def server_version(self) -> str:
100100 """Gets a string giving the server version. For example: '3.22.0'"""
101101 ...
102102
103+ @property
104+ @abc .abstractmethod
105+ def row_id_name (self ) -> str :
106+ """Gets the literal name representing a row id for this engine."""
107+ ...
108+
103109 @abc .abstractmethod
104110 def in_transaction (self , conn : ConnectionType ) -> bool :
105111 """Whether the connection is currently in a transaction."""
Original file line number Diff line number Diff line change @@ -211,6 +211,10 @@ def server_version(self) -> str:
211211 else :
212212 return "%i.%i.%i" % (numver / 10000 , (numver % 10000 ) / 100 , numver % 100 )
213213
214+ @property
215+ def row_id_name (self ) -> str :
216+ return "ctid"
217+
214218 def in_transaction (self , conn : psycopg2 .extensions .connection ) -> bool :
215219 return conn .status != psycopg2 .extensions .STATUS_READY
216220
Original file line number Diff line number Diff line change @@ -123,6 +123,10 @@ def server_version(self) -> str:
123123 """Gets a string giving the server version. For example: '3.22.0'."""
124124 return "%i.%i.%i" % sqlite3 .sqlite_version_info
125125
126+ @property
127+ def row_id_name (self ) -> str :
128+ return "rowid"
129+
126130 def in_transaction (self , conn : sqlite3 .Connection ) -> bool :
127131 return conn .in_transaction
128132
Original file line number Diff line number Diff line change 3737
3838
3939def run_create (cur : LoggingTransaction , database_engine : BaseDatabaseEngine ) -> None :
40- rowid = "ctid" if isinstance ( database_engine , PostgresEngine ) else "rowid"
40+ rowid = database_engine . row_id_name
4141
4242 # remove duplicates from group_users & group_invites tables
4343 cur .execute (
You can’t perform that action at this time.
0 commit comments