This is an automated email from the ASF dual-hosted git repository. xxyu pushed a commit to branch kylin5 in repository https://gitbox.apache.org/repos/asf/kylin.git
commit 26013268bf1b71cd3a6985d0a6bc1deafa66074c Author: Qian Xia <lauraxiaq...@gmail.com> AuthorDate: Fri Mar 24 11:21:33 2023 +0800 KYLIN-5478 upgrade sql-formatter to 8.2.0 --- kystudio/package.json | 2 +- kystudio/src/components/common/editor.vue | 8 ++++---- kystudio/src/config/index.js | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/kystudio/package.json b/kystudio/package.json index c2ed13cacb..7cedf37632 100644 --- a/kystudio/package.json +++ b/kystudio/package.json @@ -33,7 +33,7 @@ "nprogress": "0.2.0", "nvd3": "1.8.4", "smooth-scrollbar": "7.4.0", - "sql-formatter": "2.3.1", + "sql-formatter": "8.2.0", "uuid": "8.3.2", "vue": "2.5.2", "vue-clipboard2": "0.0.6", diff --git a/kystudio/src/components/common/editor.vue b/kystudio/src/components/common/editor.vue index c837c74462..83aecc434d 100644 --- a/kystudio/src/components/common/editor.vue +++ b/kystudio/src/components/common/editor.vue @@ -26,8 +26,8 @@ </div> </template> <script> -import sqlFormatter from 'sql-formatter' -import { sqlRowsLimit, sqlStrLenLimit } from '../../config/index' +import { format } from 'sql-formatter' +import { sqlRowsLimit, sqlStrLenLimit, formatSQLConfig } from '../../config/index' import { mapState } from 'vuex' import Vue from 'vue' import { Component } from 'vue-property-decorator' @@ -145,8 +145,8 @@ import { Component } from 'vue-property-decorator' const data = this.editorData.length > sqlStrLenLimit ? `${this.editorData.slice(0, sqlStrLenLimit)}...` : this.editorData // 是否显示 tips 取决于填入的 sql 字符数是否超过全局配置的 this.showLimitTip = this.editorData.length > sqlStrLenLimit - this.formatData = sqlFormatter.format(data) - this.fullFormatData = sqlFormatter.format(this.editorData) + this.formatData = format(data, formatSQLConfig) + this.fullFormatData = format(this.editorData, formatSQLConfig) } else { const data = this.editorData.split('\n') // 是否显示 tips 取决于填入的 sql 行数是否超过全局配置的 diff --git a/kystudio/src/config/index.js b/kystudio/src/config/index.js index f43fc831ef..df910cb3a2 100644 --- a/kystudio/src/config/index.js +++ b/kystudio/src/config/index.js @@ -721,4 +721,11 @@ export const getAffectedModelsType = { RELOAD_ROOT_FACT: 'RELOAD_ROOT_FACT' } +export const formatSQLConfig = { + language: 'sql', + tabWidth: 2, + // keywordCase: 'upper', + linesBetweenQueries: 2 +} + export { projectCfgs } from './projectCfgs'