Also detect missing bound values for sql.Query.run_batch
This commit is contained in:
parent
fa1fe63a93
commit
3f2a468750
@ -193,6 +193,8 @@ class Query:
|
||||
|
||||
for key, val in values.items():
|
||||
self.query.bindValue(':{}'.format(key), val)
|
||||
if any(val is None for val in self.bound_values().values()):
|
||||
raise SqlError("Missing bound values!")
|
||||
|
||||
db = QSqlDatabase.database()
|
||||
db.transaction()
|
||||
|
@ -285,6 +285,11 @@ class TestSqlQuery:
|
||||
q.run_batch(values={'answer': [42]})
|
||||
assert q.value() == 42
|
||||
|
||||
def test_run_batch_missing_binding(self):
|
||||
q = sql.Query('SELECT :answer')
|
||||
with pytest.raises(sql.SqlError, match='Missing bound values!'):
|
||||
q.run_batch(values={})
|
||||
|
||||
def test_value_missing(self):
|
||||
q = sql.Query('SELECT 0 WHERE 0')
|
||||
q.run()
|
||||
|
Loading…
Reference in New Issue
Block a user