From 7167ce41b61d2ba2cdb526777a4233eb84a3b66a Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Sat, 6 Dec 2014 17:33:25 -0500 Subject: Imported Upstream version 2.99.6 --- Plugins/SqlEnterpriseFormatter/formatwith.cpp | 38 +++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Plugins/SqlEnterpriseFormatter/formatwith.cpp (limited to 'Plugins/SqlEnterpriseFormatter/formatwith.cpp') 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(); +} -- cgit v1.2.3