Skip to content
Snippets Groups Projects
Commit cc36bd09 authored by Vincent Texier's avatar Vincent Texier
Browse files

[fix] fix python-sql error with qmark not set

parent 97f3b9f2
No related branches found
No related tags found
No related merge requests found
# Copyright 2021 Vincent Texier <vit@free.fr>
#
# This software is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from tikka.domains.application import Application
from tikka.domains.entities.account import Account
def test_accounts_list(application: Application, account: Account):
"""
Test list accounts
:param application: Application instance
:param account: Account instance
:return:
"""
application.accounts.add(account)
assert len(application.accounts.get_list()) > 0
# Copyright 2021 Vincent Texier <vit@free.fr>
#
# This software is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from tikka.domains.application import Application
def test_indexers_list(application: Application):
"""
:param application: Application instance
:param account: Account instance
:return:
"""
assert len(application.repository.indexers.list()) > 0
......@@ -30,8 +30,6 @@ from tikka.interfaces.adapters.repository.db_repository import DBRepositoryInter
TABLE_NAME = "accounts"
# config sql with ? as param style
Flavor.set(Flavor(paramstyle="qmark"))
# create sql table wrapper
sql_accounts_table = Table(TABLE_NAME)
......@@ -104,7 +102,10 @@ class DBAccountsRepository(AccountsRepositoryInterface, DBRepositoryInterface):
return And((a, b))
if len(conditions) > 0:
sql_select.where = reduce(and_, conditions)
sql_select.where = reduce(and_, conditions) # type: ignore
# config sql with ? as param style
Flavor.set(Flavor(paramstyle="qmark"))
sql, args = tuple(sql_select)
result_set = self.client.select(sql, args)
......@@ -251,7 +252,7 @@ class DBAccountsRepository(AccountsRepositoryInterface, DBRepositoryInterface):
return And((a, b))
if len(conditions) > 0:
sql_select.where = reduce(and_, conditions)
sql_select.where = reduce(and_, conditions) # type: ignore
sql, args = tuple(sql_select)
result_set = self.client.select(sql, args)
......
......@@ -23,8 +23,6 @@ from tikka.interfaces.adapters.repository.indexers import IndexersRepositoryInte
TABLE_NAME = "indexers"
# config sql with ? as param style
Flavor.set(Flavor(paramstyle="qmark"))
# create sql table wrapper
sql_indexers_table = Table(TABLE_NAME)
......@@ -74,6 +72,9 @@ class DBIndexersRepository(IndexersRepositoryInterface, DBRepositoryInterface):
# create select query wrapper without order by
sql_select = sql_indexers_table.select(offset=offset, limit=limit)
# config sql with ? as param style
Flavor.set(Flavor(paramstyle="qmark"))
sql, args = tuple(sql_select)
result_set = self.client.select(sql, args)
list_ = []
......
......@@ -1837,7 +1837,7 @@ wheels = [
[[package]]
name = "tikka"
version = "0.14.1"
version = "0.14.2"
source = { editable = "." }
dependencies = [
{ name = "dateutils" },
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment