aboutsummaryrefslogtreecommitdiffstats
path: root/SQLiteStudio3/coreSQLiteStudio/parser/ast/sqlitecommittrans.cpp
blob: 4f8de49ea3fd1f6bf01976908d05cc16aa690dc7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "sqlitecommittrans.h"
#include "sqlitequerytype.h"

#include <parser/statementtokenbuilder.h>

SqliteCommitTrans::SqliteCommitTrans()
{
    queryType = SqliteQueryType::CommitTrans;
}

SqliteCommitTrans::SqliteCommitTrans(bool transactionKw, const QString& name, bool endKw)
    : SqliteCommitTrans()
{
    this->endKw = endKw;
    this->transactionKw = transactionKw;
    this->name = name;
}

SqliteCommitTrans::SqliteCommitTrans(const SqliteCommitTrans& other) :
    SqliteQuery(other), endKw(other.endKw), name(other.name), transactionKw(other.transactionKw)
{
}

SqliteStatement* SqliteCommitTrans::clone()
{
    return new SqliteCommitTrans(*this);
}

TokenList SqliteCommitTrans::rebuildTokensFromContents()
{
    StatementTokenBuilder builder;
    builder.withTokens(SqliteQuery::rebuildTokensFromContents());
    if (endKw)
        builder.withKeyword("END");
    else
        builder.withKeyword("COMMIT");

    if (transactionKw)
    {
        builder.withSpace().withKeyword("TRANSACTION");
        if (!name.isNull())
            builder.withSpace().withOther(name);
    }

    builder.withOperator(";");

    return builder.build();
}