mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
[FIX] Prevent exception if the query doesn't return rows
This commit is contained in:
committed by
David Alonso // Solvos
parent
a515a2942a
commit
fa12f8aea4
@@ -38,5 +38,7 @@ class BaseExternalDbsource(models.Model):
|
||||
cur = connection.execute(sqlquery, sqlparams)
|
||||
if metadata:
|
||||
cols = list(cur.keys())
|
||||
rows = [r for r in cur]
|
||||
# If the query doesn't return rows, trying to get them anyway
|
||||
# will raise an exception `sqlalchemy.exc.ResourceClosedError`
|
||||
rows = [r for r in cur] if cur.returns_rows else []
|
||||
return rows, cols
|
||||
|
||||
Reference in New Issue
Block a user