blob: ac5fd7ca2253d55c7d171c9f44d4db629d63ec36 (
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
|
#include "formatcreateindex.h"
#include "parser/ast/sqlitecreateindex.h"
#include "parser/ast/sqliteindexedcolumn.h"
FormatCreateIndex::FormatCreateIndex(SqliteCreateIndex* createIndex) :
createIndex(createIndex)
{
}
void FormatCreateIndex::formatInternal()
{
handleExplainQuery(createIndex);
withKeyword("CREATE");
if (createIndex->uniqueKw)
withKeyword("UNIQUE");
withKeyword("INDEX");
if (createIndex->ifNotExistsKw)
withKeyword("IF").withKeyword("NOT").withKeyword("EXISTS");
if (dialect == Dialect::Sqlite2)
{
withId(createIndex->index).withKeyword("ON");
if (!createIndex->database.isNull())
withId(createIndex->database).withIdDot();
withId(createIndex->table).withParDefLeft().withStatementList(createIndex->indexedColumns).withParDefRight().withConflict(createIndex->onConflict);
}
else
{
if (!createIndex->database.isNull())
withId(createIndex->database).withIdDot();
withId(createIndex->index).withKeyword("ON").withId(createIndex->table).withParDefLeft().withStatementList(createIndex->indexedColumns).withParDefRight();
if (createIndex->where)
withKeyword("WHERE").withStatement(createIndex->where);
}
withSemicolon();
}
|