forked from qt-creator/qt-creator
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:
committed by
Thomas Hartmann
parent
c78d1c171f
commit
ef4f2a4dcf
@@ -42,6 +42,7 @@ public:
|
||||
Base::checkColumnCount(ResultCount);
|
||||
}
|
||||
|
||||
using Base::optionalValue;
|
||||
using Base::range;
|
||||
using Base::rangeWithTransaction;
|
||||
using Base::readCallback;
|
||||
@@ -62,6 +63,18 @@ public:
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
template<typename ResultType, typename... QueryTypes>
|
||||
auto optionalValueWithTransaction(const QueryTypes &...queryValues)
|
||||
{
|
||||
DeferredTransaction transaction{Base::database()};
|
||||
|
||||
auto resultValue = Base::template optionalValue<ResultType>(queryValues...);
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
template<typename ResultType, typename... QueryTypes>
|
||||
auto valuesWithTransaction(std::size_t reserveSize, const QueryTypes &...queryValues)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user