blob: 26709669b07191481760437c3bdef7d77c0e64d9 (
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
|
#include "formatupdate.h"
#include "parser/ast/sqliteupdate.h"
#include "parser/ast/sqliteexpr.h"
#include "formatwith.h"
FormatUpdate::FormatUpdate(SqliteUpdate* upd) :
upd(upd)
{
}
void FormatUpdate::formatInternal()
{
handleExplainQuery(upd);
if (upd->with)
withStatement(upd->with);
markKeywordLineUp("UPDATE");
withKeyword("UPDATE");
if (upd->onConflict != SqliteConflictAlgo::null)
withKeyword("OR").withKeyword(sqliteConflictAlgo(upd->onConflict));
if (!upd->database.isNull())
withId(upd->database).withIdDot();
withId(upd->table);
if (upd->indexedByKw)
withKeyword("INDEXED").withKeyword("BY").withId(upd->indexedBy);
else if (upd->notIndexedKw)
withKeyword("NOT").withKeyword("INDEXED");
withNewLine().withLinedUpKeyword("SET");
markAndKeepIndent("updateColumns");
bool first = true;
foreach (const SqliteUpdate::ColumnAndValue& keyVal, upd->keyValueMap)
{
if (!first)
withListComma();
withId(keyVal.first).withOperator("=").withStatement(keyVal.second);
first = false;
}
withDecrIndent();
if (upd->where)
withNewLine().withLinedUpKeyword("WHERE").withStatement(upd->where);
withSemicolon();
}
|