diff options
Diffstat (limited to 'Plugins/SqlEnterpriseFormatter/formatwith.cpp')
| -rw-r--r-- | Plugins/SqlEnterpriseFormatter/formatwith.cpp | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Plugins/SqlEnterpriseFormatter/formatwith.cpp b/Plugins/SqlEnterpriseFormatter/formatwith.cpp new file mode 100644 index 0000000..d3d99d5 --- /dev/null +++ b/Plugins/SqlEnterpriseFormatter/formatwith.cpp @@ -0,0 +1,38 @@ +#include "formatwith.h" +#include "parser/ast/sqliteselect.h" + +FormatWith::FormatWith(SqliteWith *with) : + with(with) +{ +} + +void FormatWith::setLineUpKeyword(const QString& kw) +{ + lineUpKeyword = kw; +} + +void FormatWith::formatInternal() +{ + markKeywordLineUp(lineUpKeyword); + + withLinedUpKeyword("WITH"); + if (with->recursive) + withKeyword("RECURSIVE"); + + withStatementList(with->cteList); +} + + +FormatWithCommonTableExpression::FormatWithCommonTableExpression(SqliteWith::CommonTableExpression *cte) : + cte(cte) +{ +} + +void FormatWithCommonTableExpression::formatInternal() +{ + withId(cte->table); + if (cte->indexedColumns.size() > 0) + withParDefLeft().withStatementList(cte->indexedColumns, "idxCols").withParDefRight(); + + withKeyword("AS").withParDefLeft().withStatement(cte->select).withParDefRight(); +} |
