mirror of
https://github.com/OCA/server-backend.git
synced 2025-02-18 09:52:42 +02:00
Merge pull request #18 from Eficent/11.0-fix-base_external_dbsource_sqlite
[11.0][FIX] base_external_dbsource_sqlite crashing when sqlparams equal None
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
# License LGPL-3.0 or later (http://www.gnu.org/licenses/lgpl).
|
||||||
{
|
{
|
||||||
'name': 'External Database Source - SQLite',
|
'name': 'External Database Source - SQLite',
|
||||||
'version': '11.0.1.0.0',
|
'version': '11.0.1.0.1',
|
||||||
'category': 'Tools',
|
'category': 'Tools',
|
||||||
'author': "Daniel Reis, "
|
'author': "Daniel Reis, "
|
||||||
"LasLabs, "
|
"LasLabs, "
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ class BaseExternalDbsource(models.Model):
|
|||||||
rows, cols = list(), list()
|
rows, cols = list(), list()
|
||||||
for record in self:
|
for record in self:
|
||||||
with record.connection_open() as connection:
|
with record.connection_open() as connection:
|
||||||
|
if sqlparams is None:
|
||||||
|
cur = connection.execute(sqlquery)
|
||||||
|
else:
|
||||||
cur = connection.execute(sqlquery, sqlparams)
|
cur = connection.execute(sqlquery, sqlparams)
|
||||||
if metadata:
|
if metadata:
|
||||||
cols = list(cur.keys())
|
cols = list(cur.keys())
|
||||||
|
|||||||
@@ -39,3 +39,12 @@ class TestBaseExternalDbsource(common.TransactionCase):
|
|||||||
) as parent_method:
|
) as parent_method:
|
||||||
self.dbsource.execute_sqlite(*expect)
|
self.dbsource.execute_sqlite(*expect)
|
||||||
parent_method.assert_called_once_with(*expect)
|
parent_method.assert_called_once_with(*expect)
|
||||||
|
|
||||||
|
def test_execute_sqlit_without_sqlparams(self):
|
||||||
|
""" It should pass args to SQLAlchemy execute """
|
||||||
|
expect = 'sqlquery', None, 'metadata'
|
||||||
|
with mock.patch.object(
|
||||||
|
self.dbsource, '_execute_sqlalchemy'
|
||||||
|
) as parent_method:
|
||||||
|
self.dbsource.execute_sqlite(*expect)
|
||||||
|
parent_method.assert_called_once_with(*expect)
|
||||||
|
|||||||
Reference in New Issue
Block a user