1
0
mirror of https://github.com/maubot/rss.git synced 2025-03-14 19:16:35 -04:00

Fix compatibility with sqlite3 before v3.35

The language feature `RETURNING` was added to sqlite3 in release v3.35.
See https://www.sqlite.org/draft/lang_returning.html

Thus the recent switch to `asyncpg` (commit 18ef939a04f) broke compatibility
with sqlite3 before v3.35.
The resulting exception was:
```
sqlite3.OperationalError: near "RETURNING": syntax error
```

Simply removing the `RETURNING (id)` suffix of the query fixes the issues
for such an older versions of sqlite3.

Situation of distributions:
* Debian Bullseye: v3.34
* Ubuntu Focal (LTS): v3.31
* Ubuntu Impish: v3.35

Thus only the most recent (non-LTS) release of Ubuntu supports this new
keyword at the moment.
This commit is contained in:
Lars Kruse 2022-04-17 22:23:19 +02:00
parent b9bc6fbc81
commit c47d01fa83

@ -180,7 +180,7 @@ class DBManager:
async def create_feed(self, info: Feed) -> Feed: async def create_feed(self, info: Feed) -> Feed:
q = ( q = (
"INSERT INTO feed (url, title, subtitle, link, next_retry) " "INSERT INTO feed (url, title, subtitle, link, next_retry) "
"VALUES ($1, $2, $3, $4, $5) RETURNING (id)" "VALUES ($1, $2, $3, $4, $5)"
) )
info.id = await self.db.fetchval( info.id = await self.db.fetchval(
q, info.url, info.title, info.subtitle, info.link, info.next_retry q, info.url, info.title, info.subtitle, info.link, info.next_retry