blob: 359396b43c21ca4bb8130893a9ecafcd1028df20 (
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
|
#include "sqliteattach.h"
#include "sqlitequerytype.h"
#include "sqliteexpr.h"
#include "parser/statementtokenbuilder.h"
#include "common/global.h"
SqliteAttach::SqliteAttach()
{
queryType = SqliteQueryType::Attach;
}
SqliteAttach::SqliteAttach(bool dbKw, SqliteExpr *url, SqliteExpr *name, SqliteExpr *key)
: SqliteAttach()
{
databaseKw = dbKw;
databaseUrl = url;
this->name = name;
this->key = key;
if (databaseUrl)
databaseUrl->setParent(this);
if (name)
name->setParent(this);
if (key)
key->setParent(this);
}
SqliteAttach::SqliteAttach(const SqliteAttach& other) :
SqliteQuery(other), databaseKw(other.databaseKw)
{
DEEP_COPY_FIELD(SqliteExpr, databaseUrl);
DEEP_COPY_FIELD(SqliteExpr, name);
DEEP_COPY_FIELD(SqliteExpr, key);
}
SqliteAttach::~SqliteAttach()
{
}
SqliteStatement* SqliteAttach::clone()
{
return new SqliteAttach(*this);
}
TokenList SqliteAttach::rebuildTokensFromContents()
{
StatementTokenBuilder builder;
builder.withTokens(SqliteQuery::rebuildTokensFromContents());
builder.withKeyword("ATTACH").withSpace();
if (databaseKw)
builder.withKeyword("DATABASE").withSpace();
builder.withStatement(databaseUrl).withSpace().withKeyword("AS").withSpace().withStatement(name);
if (key)
builder.withSpace().withKeyword("KEY").withSpace().withStatement(key);
builder.withOperator(";");
return builder.build();
}
|