Sqlite: Add unoptional value fetcher

There is now value, valueWithTransaction, optionalValue and
optionalValueWithTransaction. Sometimes you want to return
the default constructed value as default. So this is now possible.
This simplifies some code but can be even more optimal.

Change-Id: Ibbb6b5ca47803344ed646bfa257602b6db52e0fe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
Marco Bubke
2021-04-29 19:33:07 +02:00
committed by Thomas Hartmann
parent c78d1c171f
commit ef4f2a4dcf
11 changed files with 175 additions and 38 deletions

View File

@@ -161,7 +161,7 @@ public:
(int projectPartId));
template<typename ResultType, typename... QueryTypes>
auto value(const QueryTypes &...queryValues)
auto optionalValue(const QueryTypes &...queryValues)
{
if constexpr (std::is_same_v<ResultType, Sqlite::ByteArrayBlob>)
return valueReturnBlob(queryValues...);
@@ -196,6 +196,19 @@ public:
"SqliteReadStatementMock::value does not handle result type!");
}
template<typename ResultType, typename... QueryTypes>
auto value(const QueryTypes &...queryValues)
{
static_assert(!std::is_same_v<ResultType, ResultType>,
"SqliteReadStatementMock::value does not handle result type!");
}
template<typename ResultType, typename... QueryTypes>
auto optionalValueWithTransaction(const QueryTypes &...queryValues)
{
return optionalValue<ResultType>(queryValues...);
}
template<typename ResultType, typename... QueryType>
auto values(std::size_t reserveSize, const QueryType &...queryValues)
{