blob: 899f8bbd84961ed3488f6124bc53fab8cc81b9bf (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
#include "sqlitebegintrans.h"
#include "sqlitequerytype.h"
#include <parser/statementtokenbuilder.h>
SqliteBeginTrans::SqliteBeginTrans()
{
queryType = SqliteQueryType::BeginTrans;
}
SqliteBeginTrans::SqliteBeginTrans(const SqliteBeginTrans& other) :
SqliteQuery(other), name(other.name), transactionKw(other.transactionKw), type(other.type)
{
}
SqliteBeginTrans::SqliteBeginTrans(SqliteBeginTrans::Type type, bool transactionKw, const QString& name)
: SqliteBeginTrans()
{
this->type = type;
this->transactionKw = transactionKw;
this->name = name;
}
SqliteBeginTrans::SqliteBeginTrans(bool transactionKw, const QString &name)
{
this->transactionKw = transactionKw;
this->name = name;
}
SqliteStatement*SqliteBeginTrans::clone()
{
return new SqliteBeginTrans(*this);
}
QString SqliteBeginTrans::typeToString(SqliteBeginTrans::Type type)
{
switch (type)
{
case Type::null:
return QString();
case Type::DEFERRED:
return "DEFERRED";
case Type::IMMEDIATE:
return "IMMEDIATE";
case Type::EXCLUSIVE:
return "EXCLUSIVE";
}
return QString();
}
TokenList SqliteBeginTrans::rebuildTokensFromContents()
{
StatementTokenBuilder builder;
builder.withTokens(SqliteQuery::rebuildTokensFromContents());
builder.withKeyword("BEGIN");
if (type != Type::null)
builder.withSpace().withKeyword(typeToString(type));
if (transactionKw)
{
builder.withSpace().withKeyword("TRANSACTION");
if (!name.isNull())
builder.withSpace().withOther(name);
}
builder.withOperator(";");
return builder.build();
}
|