From feda8a7db8d1d7c5439aa8f8feef7cc0dd2b59a0 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Fri, 27 Jul 2018 23:51:12 -0400 Subject: New upstream version 3.2.1+dfsg1 --- .../SqlEnterpriseFormatter.pro | 10 +- .../SqlEnterpriseFormatter_fr.qm | Bin 6264 -> 6266 bytes .../SqlEnterpriseFormatter_ro_RO.qm | Bin 0 -> 30 bytes .../SqlEnterpriseFormatter_ro_RO.ts | 228 +++++++++++++++++++++ .../SqlEnterpriseFormatter_ru.qm | Bin 6230 -> 6230 bytes .../SqlEnterpriseFormatter_ru.ts | 2 +- .../SqlEnterpriseFormatter/formatcreatetable.cpp | 2 +- Plugins/SqlEnterpriseFormatter/formatinsert.cpp | 5 + Plugins/SqlEnterpriseFormatter/formatselect.cpp | 24 ++- Plugins/SqlEnterpriseFormatter/formatstatement.cpp | 5 +- Plugins/SqlEnterpriseFormatter/formatupdate.cpp | 8 +- Plugins/SqlEnterpriseFormatter/formatupsert.cpp | 49 +++++ Plugins/SqlEnterpriseFormatter/formatupsert.h | 19 ++ Plugins/SqlEnterpriseFormatter/package.xml | 10 + .../sqlenterpriseformatter.qrc | 2 + 15 files changed, 352 insertions(+), 12 deletions(-) create mode 100644 Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.qm create mode 100644 Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.ts create mode 100644 Plugins/SqlEnterpriseFormatter/formatupsert.cpp create mode 100644 Plugins/SqlEnterpriseFormatter/formatupsert.h create mode 100644 Plugins/SqlEnterpriseFormatter/package.xml (limited to 'Plugins/SqlEnterpriseFormatter') diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro index 2d5b88c..a00ab89 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter.pro @@ -49,7 +49,8 @@ SOURCES += sqlenterpriseformatter.cpp \ formatrollback.cpp \ formatsavepoint.cpp \ formatvacuum.cpp \ - formatorderby.cpp + formatorderby.cpp \ + formatupsert.cpp HEADERS += sqlenterpriseformatter.h\ sqlenterpriseformatter_global.h \ @@ -88,7 +89,8 @@ HEADERS += sqlenterpriseformatter.h\ formatrollback.h \ formatsavepoint.h \ formatvacuum.h \ - formatorderby.h + formatorderby.h \ + formatupsert.h OTHER_FILES += \ sqlenterpriseformatter.json @@ -100,7 +102,8 @@ RESOURCES += \ sqlenterpriseformatter.qrc -TRANSLATIONS += SqlEnterpriseFormatter_de.ts \ +TRANSLATIONS += SqlEnterpriseFormatter_ro_RO.ts \ + SqlEnterpriseFormatter_de.ts \ SqlEnterpriseFormatter_it.ts \ SqlEnterpriseFormatter_zh_CN.ts \ SqlEnterpriseFormatter_sk.ts \ @@ -124,3 +127,4 @@ TRANSLATIONS += SqlEnterpriseFormatter_de.ts \ + diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm index 40423d9..974d221 100644 Binary files a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm and b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_fr.qm differ diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.qm b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.qm new file mode 100644 index 0000000..2856eb9 Binary files /dev/null and b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.qm differ diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.ts new file mode 100644 index 0000000..c1d1b7b --- /dev/null +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ro_RO.ts @@ -0,0 +1,228 @@ + + + + + QObject + + + + name + example name wrapper + + + + + SqlEnterpriseFormatter + + + Indentation + + + + + Line up keywords in multi-line queries + + + + + Indent contents of parenthesis block + + + + + Tab size: + + + + + New lines + + + + + Before opening parenthesis in column definitions + + + + + After opening parenthesis in column definitions + + + + + Before closing parenthesis in column definitions + + + + + After closing parenthesis in column definitions + + + + + Before opening parenthesis in expressions + + + + + After opening parenthesis in expressions + + + + + Before closing parenthesis in expressions + + + + + After closing parenthesis in expressions + + + + + After JOIN keywords in FROM clause + + + + + Put each column constraint in CREATE TABLE into new line + + + + + After comma + + + + + After comma in expressions + + + + + After semicolon + + + + + + Never before semicolon + + + + + White spaces + + + + + Before comma in lists + + + + + After comma in lists + + + + + Before opening parenthesis + + + + + After opening parenthesis + + + + + Before closing parenthesis + + + + + After closing parenthesis + + + + + No space between SQL function name and opening parenthesis + + + + + Before dot operator (in path to database object) + + + + + After dot operator (in path to database object) + + + + + Before mathematical operator + + + + + After mathematical operator + + + + + Never before comma + + + + + Names + + + + + Preferred name wrapper + + + + + Always use name wrapping + + + + + Uppercase data type names + + + + + Uppercase keywords + + + + + Comments + + + + + Preferred comment marker (where possible): + + + + + Move all comments to the line end + + + + + Line up comments at the line end + + + + + Preview + + + + diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.qm b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.qm index e4d3522..07f5b2e 100644 Binary files a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.qm and b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.qm differ diff --git a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts index 8e942c9..54cf8ad 100644 --- a/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts +++ b/Plugins/SqlEnterpriseFormatter/SqlEnterpriseFormatter_ru.ts @@ -147,7 +147,7 @@ No space between SQL function name and opening parenthesis - Не ставить пробел между именем функции SQL и открывающкй скобкой + Не ставить пробел между именем функции SQL и открывающей скобкой diff --git a/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp b/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp index d1f0996..6ac6226 100644 --- a/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatcreatetable.cpp @@ -48,7 +48,7 @@ void FormatCreateTable::formatColumns(const QList& c int maxColNameIndent = 0; int maxColTypeIndent = 0; FormatColumnType* formatColType = nullptr; - foreach (SqliteCreateTable::Column* stmt, columns) + for (SqliteCreateTable::Column* stmt : columns) { maxColNameIndent = qMax(getColNameLength(stmt->name), maxColNameIndent); diff --git a/Plugins/SqlEnterpriseFormatter/formatinsert.cpp b/Plugins/SqlEnterpriseFormatter/formatinsert.cpp index 6c1e763..2a49cfd 100644 --- a/Plugins/SqlEnterpriseFormatter/formatinsert.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatinsert.cpp @@ -1,6 +1,7 @@ #include "formatinsert.h" #include "parser/ast/sqliteselect.h" #include "parser/ast/sqliteinsert.h" +#include "parser/ast/sqliteupsert.h" #include "formatwith.h" FormatInsert::FormatInsert(SqliteInsert* insert) : @@ -49,7 +50,11 @@ void FormatInsert::formatInternal() { withKeyword("VALUES").withParDefLeft().withStatementList(insert->values).withParDefRight(); } + if (insert->upsert) + withStatement(insert->upsert); + withDecrIndent(); } + withSemicolon(); } diff --git a/Plugins/SqlEnterpriseFormatter/formatselect.cpp b/Plugins/SqlEnterpriseFormatter/formatselect.cpp index d2173c5..f5aa55e 100644 --- a/Plugins/SqlEnterpriseFormatter/formatselect.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatselect.cpp @@ -142,11 +142,27 @@ void FormatSelectCoreSingleSource::formatInternal() withKeyword("AS"); withId(singleSource->alias); + } + + if (singleSource->indexedByKw) + withKeyword("INDEXED").withKeyword("BY").withId(singleSource->indexedBy); + else if (singleSource->notIndexedKw) + withKeyword("NOT").withKeyword("INDEXED"); + } + else if (!singleSource->funcName.isNull()) + { + if (!singleSource->database.isNull()) + withId(singleSource->database).withIdDot(); + + withId(singleSource->funcName).withParFuncLeft() + .withStatementList(singleSource->funcParams, "funcArgs", FormatStatement::ListSeparator::EXPR_COMMA).withParFuncRight(); - if (singleSource->indexedByKw) - withKeyword("INDEXED").withKeyword("BY").withId(singleSource->indexedBy); - else if (singleSource->notIndexedKw) - withKeyword("NOT").withKeyword("INDEXED"); + if (!singleSource->alias.isNull()) + { + if (singleSource->asKw) + withKeyword("AS"); + + withId(singleSource->alias); } } else if (singleSource->select) diff --git a/Plugins/SqlEnterpriseFormatter/formatstatement.cpp b/Plugins/SqlEnterpriseFormatter/formatstatement.cpp index 2faaa16..fbfec2b 100644 --- a/Plugins/SqlEnterpriseFormatter/formatstatement.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatstatement.cpp @@ -28,6 +28,7 @@ #include "formatdroptrigger.h" #include "formatdropview.h" #include "formatorderby.h" +#include "formatupsert.h" #include "parser/ast/sqliteselect.h" #include "parser/ast/sqliteexpr.h" #include "parser/ast/sqlitelimit.h" @@ -57,6 +58,7 @@ #include "parser/ast/sqlitedropview.h" #include "parser/ast/sqliteorderby.h" #include "parser/ast/sqlitepragma.h" +#include "parser/ast/sqliteupsert.h" #include "sqlenterpriseformatter.h" #include "common/utils_sql.h" #include "common/global.h" @@ -132,6 +134,7 @@ FormatStatement *FormatStatement::forQuery(SqliteStatement *query) FORMATTER_FACTORY_ENTRY(query, SqliteColumnType, FormatColumnType); FORMATTER_FACTORY_ENTRY(query, SqliteIndexedColumn, FormatIndexedColumn); FORMATTER_FACTORY_ENTRY(query, SqliteInsert, FormatInsert); + FORMATTER_FACTORY_ENTRY(query, SqliteUpsert, FormatUpsert); FORMATTER_FACTORY_ENTRY(query, SqliteEmptyQuery, FormatEmpty); FORMATTER_FACTORY_ENTRY(query, SqliteAlterTable, FormatAlterTable); FORMATTER_FACTORY_ENTRY(query, SqliteAnalyze, FormatAnalyze); @@ -472,7 +475,7 @@ FormatStatement& FormatStatement::withIdList(const QStringList& names, const QSt markAndKeepIndent(indentName); bool first = true; - foreach (const QString& name, names) + for (const QString& name : names) { if (!first) withSeparator(sep); diff --git a/Plugins/SqlEnterpriseFormatter/formatupdate.cpp b/Plugins/SqlEnterpriseFormatter/formatupdate.cpp index 2670966..641c895 100644 --- a/Plugins/SqlEnterpriseFormatter/formatupdate.cpp +++ b/Plugins/SqlEnterpriseFormatter/formatupdate.cpp @@ -34,12 +34,16 @@ void FormatUpdate::formatInternal() markAndKeepIndent("updateColumns"); bool first = true; - foreach (const SqliteUpdate::ColumnAndValue& keyVal, upd->keyValueMap) + for (const SqliteUpdate::ColumnAndValue& keyVal : upd->keyValueMap) { if (!first) withListComma(); - withId(keyVal.first).withOperator("=").withStatement(keyVal.second); + if (keyVal.first.type() == QVariant::StringList) + withParDefLeft().withIdList(keyVal.first.toStringList()).withParDefRight().withOperator("=").withStatement(keyVal.second); + else + withId(keyVal.first.toString()).withOperator("=").withStatement(keyVal.second); + first = false; } diff --git a/Plugins/SqlEnterpriseFormatter/formatupsert.cpp b/Plugins/SqlEnterpriseFormatter/formatupsert.cpp new file mode 100644 index 0000000..70992f9 --- /dev/null +++ b/Plugins/SqlEnterpriseFormatter/formatupsert.cpp @@ -0,0 +1,49 @@ +#include "formatupsert.h" +#include "parser/ast/sqliteupsert.h" +#include "parser/ast/sqliteexpr.h" +#include "parser/ast/sqliteorderby.h" + +FormatUpsert::FormatUpsert(SqliteUpsert* upsert) : + upsert(upsert) +{ + +} + +void FormatUpsert::formatInternal() +{ + withKeyword("ON").withKeyword("CONFLICT"); + if (!upsert->conflictColumns.isEmpty()) + { + withParDefLeft().withStatementList(upsert->conflictColumns).withParDefRight(); + if (upsert->conflictWhere) + withKeyword("WHERE").withStatement(upsert->conflictWhere); + } + + withKeyword("DO"); + + if (upsert->doNothing) + { + withKeyword("NOTHING"); + } + else + { + withKeyword("UPDATE").withKeyword("SET"); + bool first = true; + for (const SqliteUpsert::ColumnAndValue& keyVal : upsert->keyValueMap) + { + if (!first) + withListComma(); + + if (keyVal.first.type() == QVariant::StringList) + withParDefLeft().withIdList(keyVal.first.toStringList()).withParDefRight().withOperator("=").withStatement(keyVal.second); + else + withId(keyVal.first.toString()).withOperator("=").withStatement(keyVal.second); + + first = false; + } + + if (upsert->setWhere) + withKeyword("WHERE").withStatement(upsert->setWhere); + } + +} diff --git a/Plugins/SqlEnterpriseFormatter/formatupsert.h b/Plugins/SqlEnterpriseFormatter/formatupsert.h new file mode 100644 index 0000000..3aca8f8 --- /dev/null +++ b/Plugins/SqlEnterpriseFormatter/formatupsert.h @@ -0,0 +1,19 @@ +#ifndef FORMATUPSERT_H +#define FORMATUPSERT_H + +#include "formatstatement.h" + +class SqliteUpsert; + +class FormatUpsert : public FormatStatement +{ + public: + FormatUpsert(SqliteUpsert* upsert); + + void formatInternal(); + + private: + SqliteUpsert* upsert = nullptr; +}; + +#endif // FORMATUPSERT_H diff --git a/Plugins/SqlEnterpriseFormatter/package.xml b/Plugins/SqlEnterpriseFormatter/package.xml new file mode 100644 index 0000000..643cd6a --- /dev/null +++ b/Plugins/SqlEnterpriseFormatter/package.xml @@ -0,0 +1,10 @@ + + + SQL enterprise formatter plugin + Plugin for advanced, highly customizable SQL formatting. + %VERSION% + %DATE% + pl.com.salsoft.sqlitestudio.plugins.sqlenterpriseformatter + pl.com.salsoft.sqlitestudio.plugins + true + \ No newline at end of file diff --git a/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc b/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc index 839720f..6fde81d 100644 --- a/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc +++ b/Plugins/SqlEnterpriseFormatter/sqlenterpriseformatter.qrc @@ -3,6 +3,7 @@ sqlenterpriseformatter.ui + SqlEnterpriseFormatter_ro_RO.qm SqlEnterpriseFormatter_de.qm @@ -16,3 +17,4 @@ + -- cgit v1.2.3