Skip to content

Commit 5386361

Browse files
committed
Remove git beginTransaction
1 parent ffe156b commit 5386361

7 files changed

Lines changed: 5 additions & 42 deletions

File tree

demos/async1/coroutines.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
4545

4646
auto db = co_await APool::database();
4747

48-
auto transaction = co_await db->beginTransaction();
48+
auto transaction = co_await db->begin();
4949
qDebug() << "transaction started";
5050

5151
auto result = co_await db->exec(u8"SELECT now()");

src/adatabase.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,7 @@ bool ADatabase::isOpen() const
122122
return d != nullptr && d->isOpen();
123123
}
124124

125-
AExpectedResult ADatabase::begin(QObject *receiver)
126-
{
127-
Q_ASSERT(d);
128-
AExpectedResult coro(receiver);
129-
d->begin(d, receiver, coro.ref());
130-
return coro;
131-
}
132-
133-
AExpectedTransaction ADatabase::beginTransaction(QObject *receiver)
125+
AExpectedTransaction ADatabase::begin(QObject *receiver)
134126
{
135127
Q_ASSERT(d);
136128
AExpectedTransaction coro(receiver);

src/adatabase.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -291,21 +291,13 @@ class ASQL_EXPORT ADatabase
291291
*/
292292
[[nodiscard]] bool isOpen() const;
293293

294-
/*!
295-
* \brief begin a transaction, this operation usually succeeds,
296-
* but one can hook up a callback to check it's result.
297-
*
298-
* \param cb
299-
*/
300-
[[nodiscard]] AExpectedResult begin(QObject *receiver = nullptr);
301-
302294
/*!
303295
* \brief begin a transaction with a RAII object, this operation usually succeeds,
304296
* but one can hook up a callback to check it's result.
305297
*
306298
* \param cb
307299
*/
308-
[[nodiscard]] AExpectedTransaction beginTransaction(QObject *receiver = nullptr);
300+
[[nodiscard]] AExpectedTransaction begin(QObject *receiver = nullptr);
309301

310302
/*!
311303
* \brief commit a transaction, this operation usually succeeds,

src/amigrations.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ ACoroTerminator AMigrations::migrate(int targetVersion,
265265
co_return;
266266
}
267267

268-
auto t = co_await d->db.beginTransaction();
268+
auto t = co_await d->db.begin();
269269
if (!t) {
270270
cb(true, t.error());
271271
co_return;

src/atransaction.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,6 @@ ATransaction &ATransaction::operator=(const ATransaction &copy)
7777
return *this;
7878
}
7979

80-
AExpectedResult ATransaction::begin(QObject *receiver)
81-
{
82-
Q_ASSERT(d);
83-
if (!d->running) {
84-
d->running = true;
85-
return d->db.begin(receiver);
86-
} else {
87-
qWarning(ASQL_TRANSACTION, "Transaction already started");
88-
}
89-
90-
return {receiver};
91-
}
92-
9380
AExpectedResult ATransaction::commit(QObject *receiver)
9481
{
9582
Q_ASSERT(d);

src/atransaction.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,6 @@ class ASQL_EXPORT ATransaction
4848
*/
4949
static ATransaction fromStarted(const ADatabase &db);
5050

51-
/*!
52-
* \brief begin a transaction, this operation usually succeeds,
53-
* but one can hook up a callback to check it's result.
54-
*
55-
* \param cb
56-
*/
57-
[[nodiscard]] AExpectedResult begin(QObject *receiver = nullptr);
58-
5951
/*!
6052
* \brief commit a transaction only if our usage count equals 1
6153
*

tests/sqlite_tst.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void TestSqlite::testQueries()
138138
AVERIFY(db);
139139

140140
// TODO use APool::begin() once new coro class is ready
141-
auto t = co_await db->beginTransaction(nullptr);
141+
auto t = co_await db->begin(nullptr);
142142
AVERIFY(t);
143143
AVERIFY(t->database().isValid());
144144

0 commit comments

Comments
 (0)