diff options
Diffstat (limited to 'Plugins/SqlEnterpriseFormatter/formatcreateindex.cpp')
| -rw-r--r-- | Plugins/SqlEnterpriseFormatter/formatcreateindex.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Plugins/SqlEnterpriseFormatter/formatcreateindex.cpp b/Plugins/SqlEnterpriseFormatter/formatcreateindex.cpp new file mode 100644 index 0000000..cc8f3f6 --- /dev/null +++ b/Plugins/SqlEnterpriseFormatter/formatcreateindex.cpp @@ -0,0 +1,42 @@ +#include "formatcreateindex.h" +#include "parser/ast/sqlitecreateindex.h" +#include "parser/ast/sqliteindexedcolumn.h" + +FormatCreateIndex::FormatCreateIndex(SqliteCreateIndex* createIndex) : + createIndex(createIndex) +{ +} + +void FormatCreateIndex::formatInternal() +{ + 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(); +} |
