forked from qt-creator/qt-creator
Sqlite: Add *WithTransaction fetcher
There are many simply fetch functions which can now be simplified. Change-Id: Ibf542ee8b07a1b06ea3dae695da1f69065e9dd71 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
@@ -50,6 +50,50 @@ public:
|
||||
using Base::value;
|
||||
using Base::values;
|
||||
|
||||
template<typename ResultType, typename... QueryTypes>
|
||||
auto valueWithTransaction(const QueryTypes &...queryValues)
|
||||
{
|
||||
DeferredTransaction transaction{Base::database()};
|
||||
|
||||
auto resultValue = Base::template value<ResultType>(queryValues...);
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return resultValue;
|
||||
}
|
||||
|
||||
template<typename ResultType, typename... QueryTypes>
|
||||
auto valuesWithTransaction(std::size_t reserveSize, const QueryTypes &...queryValues)
|
||||
{
|
||||
DeferredTransaction transaction{Base::database()};
|
||||
|
||||
auto resultValues = Base::template values<ResultType>(reserveSize, queryValues...);
|
||||
|
||||
transaction.commit();
|
||||
|
||||
return resultValues;
|
||||
}
|
||||
|
||||
template<typename Callable, typename... QueryTypes>
|
||||
void readCallbackWithTransaction(Callable &&callable, const QueryTypes &...queryValues)
|
||||
{
|
||||
DeferredTransaction transaction{Base::database()};
|
||||
|
||||
Base::readCallback(std::forward<Callable>(callable), queryValues...);
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
template<typename Container, typename... QueryTypes>
|
||||
void readToWithTransaction(Container &container, const QueryTypes &...queryValues)
|
||||
{
|
||||
DeferredTransaction transaction{Base::database()};
|
||||
|
||||
Base::readTo(container, queryValues...);
|
||||
|
||||
transaction.commit();
|
||||
}
|
||||
|
||||
protected:
|
||||
void checkIsReadOnlyStatement()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user