diff options
Diffstat (limited to 'Plugins/SqlEnterpriseFormatter/formatselect.cpp')
| -rw-r--r-- | Plugins/SqlEnterpriseFormatter/formatselect.cpp | 63 |
1 files changed, 21 insertions, 42 deletions
diff --git a/Plugins/SqlEnterpriseFormatter/formatselect.cpp b/Plugins/SqlEnterpriseFormatter/formatselect.cpp index f5aa55e..37559eb 100644 --- a/Plugins/SqlEnterpriseFormatter/formatselect.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatselect.cpp @@ -1,6 +1,7 @@ #include "formatselect.h" #include "formatwith.h" #include "parser/ast/sqlitewith.h" +#include "parser/ast/sqlitewindowdefinition.h" FormatSelect::FormatSelect(SqliteSelect* select) : select(select) @@ -86,6 +87,13 @@ void FormatSelectCore::formatInternal() if (core->having) withNewLine().withLinedUpKeyword("HAVING", "selectCore").withStatement(core->having, "having"); + if (core->windows.size() > 0) + { + withNewLine().withLinedUpKeyword("WINDOW", "selectCore"); + markKeywordLineUp("WINDOW", "selectWindow"); + withStatementList(core->windows, "selectWindow"); + } + if (core->orderBy.size() > 0) withNewLine().withLinedUpKeyword("ORDER", "selectCore").withKeyword("BY").withStatementList(core->orderBy, "order"); @@ -197,50 +205,21 @@ void FormatSelectCoreJoinOp::formatInternal() withNewLine(); QStringList keywords; - switch (dialect) - { - case Dialect::Sqlite3: - { - if (joinOp->naturalKw) - keywords << "NATURAL"; + if (joinOp->naturalKw) + keywords << "NATURAL"; - if (joinOp->leftKw) - { - keywords << "LEFT"; - if (joinOp->outerKw) - keywords << "OUTER"; - } - else if (joinOp->innerKw) - keywords << "INNER"; - else if (joinOp->crossKw) - keywords << "CROSS"; - - keywords << "JOIN"; - break; - } - case Dialect::Sqlite2: - { - if (joinOp->naturalKw) - keywords << "NATURAL"; - - if (joinOp->leftKw) - keywords << "LEFT"; - else if (joinOp->rightKw) - keywords << "RIGHT"; - else if (joinOp->fullKw) - keywords << "FULL"; - - if (joinOp->innerKw) - keywords << "INNER"; - else if (joinOp->crossKw) - keywords << "CROSS"; - else if (joinOp->outerKw) - keywords << "OUTER"; - - keywords << "JOIN"; - break; - } + if (joinOp->leftKw) + { + keywords << "LEFT"; + if (joinOp->outerKw) + keywords << "OUTER"; } + else if (joinOp->innerKw) + keywords << "INNER"; + else if (joinOp->crossKw) + keywords << "CROSS"; + + keywords << "JOIN"; if (keywords.size() == 0) return; |
