Sqlite: Introduce BindParameterCount template parameter

The BindParameterCount is checked at compile time and then again for
the construction of the statement. So we provide an early error instead of
an some error later or even stranger behavior.

Change-Id: I860ca1f78645c222ae1accf5c7a469c77befc3bd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
Marco Bubke
2021-12-07 17:28:38 +01:00
parent 4e69b0a689
commit d4c6f06a63
22 changed files with 389 additions and 387 deletions

View File

@@ -121,9 +121,10 @@ protected:
database};
Sqlite::ReadStatement<2> selectValuesStatement{"SELECT key, value FROM data ORDER BY key",
database};
Sqlite::WriteStatement insertStatement{"INSERT INTO data(key, value) VALUES (?1, ?2)", database};
Sqlite::WriteStatement updateStatement{"UPDATE data SET value = ?2 WHERE key=?1", database};
Sqlite::WriteStatement deleteStatement{"DELETE FROM data WHERE key=?", database};
Sqlite::WriteStatement<2> insertStatement{"INSERT INTO data(key, value) VALUES (?1, ?2)",
database};
Sqlite::WriteStatement<2> updateStatement{"UPDATE data SET value = ?2 WHERE key=?1", database};
Sqlite::WriteStatement<1> deleteStatement{"DELETE FROM data WHERE key=?", database};
std::function<void(const KeyValue &keyValue)> insert{
[&](const KeyValue &keyValue) { insertStatement.write(keyValue.key, keyValue.value); }};
std::function<Sqlite::UpdateChange(KeyValueView keyValueView, const KeyValue &keyValue)> update{