mirror of
https://github.com/maubot/rss.git
synced 2025-07-05 19:34:49 -04:00
parent
b9bc6fbc81
commit
35f2fe63df
1 changed files with 18 additions and 4 deletions
16
rss/db.py
16
rss/db.py
|
@ -23,7 +23,7 @@ from attr import dataclass
|
|||
import attr
|
||||
|
||||
from mautrix.types import RoomID, UserID
|
||||
from mautrix.util.async_db import Database, Scheme
|
||||
from mautrix.util.async_db import Database, Scheme, SQLiteCursor
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -182,6 +182,20 @@ class DBManager:
|
|||
"INSERT INTO feed (url, title, subtitle, link, next_retry) "
|
||||
"VALUES ($1, $2, $3, $4, $5) RETURNING (id)"
|
||||
)
|
||||
# SQLite only gained RETURNING support in v3.35 (2021-03-12)
|
||||
# TODO remove this special case in a couple of years
|
||||
if self.db.scheme == Scheme.SQLITE:
|
||||
cur = await self.db.execute(
|
||||
q.replace(" RETURNING (id)", ""),
|
||||
info.url,
|
||||
info.title,
|
||||
info.subtitle,
|
||||
info.link,
|
||||
info.next_retry,
|
||||
)
|
||||
assert isinstance(cur, SQLiteCursor)
|
||||
info.id = cur.lastrowid
|
||||
else:
|
||||
info.id = await self.db.fetchval(
|
||||
q, info.url, info.title, info.subtitle, info.link, info.next_retry
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue