diff --git a/packages/api/package.json b/packages/api/package.json index e3f0c90d..8190e580 100644 --- a/packages/api/package.json +++ b/packages/api/package.json @@ -25,7 +25,7 @@ "compare-versions": "^3.6.0", "cors": "^2.8.5", "cross-env": "^6.0.3", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "dbgate-sqltree": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1", "debug": "^4.3.4", diff --git a/packages/api/src/shell/importDatabase.js b/packages/api/src/shell/importDatabase.js index 7ad1fbfc..6cb52961 100644 --- a/packages/api/src/shell/importDatabase.js +++ b/packages/api/src/shell/importDatabase.js @@ -47,7 +47,7 @@ async function importDatabase({ connection = undefined, systemConnection = undef const downloadedFile = await download(inputFile); const fileStream = fs.createReadStream(downloadedFile, 'utf-8'); - const splittedStream = splitQueryStream(fileStream, driver.getQuerySplitterOptions()); + const splittedStream = splitQueryStream(fileStream, driver.getQuerySplitterOptions('script')); const importStream = new ImportStream(pool, driver); // @ts-ignore splittedStream.pipe(importStream); diff --git a/packages/tools/package.json b/packages/tools/package.json index 17001d95..52e8d17a 100644 --- a/packages/tools/package.json +++ b/packages/tools/package.json @@ -31,7 +31,7 @@ "typescript": "^4.4.3" }, "dependencies": { - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "dbgate-sqltree": "^5.0.0-alpha.1", "debug": "^4.3.4", "json-stable-stringify": "^1.0.1", diff --git a/packages/types/engines.d.ts b/packages/types/engines.d.ts index cc15d56d..39ac9204 100644 --- a/packages/types/engines.d.ts +++ b/packages/types/engines.d.ts @@ -89,9 +89,7 @@ export interface EngineDriver { ): Promise; analyseSingleTable(pool: any, name: NamedObjectInfo): Promise; getVersion(pool: any): Promise<{ version: string }>; - listDatabases( - pool: any - ): Promise< + listDatabases(pool: any): Promise< { name: string; }[] @@ -112,7 +110,7 @@ export interface EngineDriver { updateCollection(pool: any, changeSet: any): Promise; getCollectionUpdateScript(changeSet: any): string; createDatabase(pool: any, name: string): Promise; - getQuerySplitterOptions(usage: 'stream' | 'script'): any; + getQuerySplitterOptions(usage: 'stream' | 'script' | 'editor'): any; script(pool: any, sql: string): Promise; getNewObjectTemplates(): NewObjectTemplate[]; // direct call of pool method, only some methods could be supported, on only some drivers diff --git a/packages/web/package.json b/packages/web/package.json index 0be497b5..ce096543 100644 --- a/packages/web/package.json +++ b/packages/web/package.json @@ -24,7 +24,7 @@ "chartjs-adapter-moment": "^1.0.0", "cross-env": "^7.0.3", "dbgate-datalib": "^5.0.0-alpha.1", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "dbgate-sqltree": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1", "dbgate-types": "^5.0.0-alpha.1", diff --git a/packages/web/src/tabs/QueryTab.svelte b/packages/web/src/tabs/QueryTab.svelte index e925dc09..fefb5adf 100644 --- a/packages/web/src/tabs/QueryTab.svelte +++ b/packages/web/src/tabs/QueryTab.svelte @@ -293,7 +293,7 @@ engine={$connection && $connection.engine} {conid} {database} - splitterOptions={driver?.getQuerySplitterOptions('script')} + splitterOptions={driver?.getQuerySplitterOptions('editor')} value={$editorState.value || ''} menu={createMenu()} on:input={e => { @@ -312,7 +312,7 @@ setEditorData(e.detail)} on:focus={() => { diff --git a/plugins/dbgate-plugin-mongo/package.json b/plugins/dbgate-plugin-mongo/package.json index 85e4c0a5..a0329c95 100644 --- a/plugins/dbgate-plugin-mongo/package.json +++ b/plugins/dbgate-plugin-mongo/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "dbgate-plugin-tools": "^1.0.7", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "webpack": "^4.42.0", "webpack-cli": "^3.3.11", "dbgate-tools": "^5.0.0-alpha.1", diff --git a/plugins/dbgate-plugin-mssql/package.json b/plugins/dbgate-plugin-mssql/package.json index d3f06e9d..6e93fde5 100644 --- a/plugins/dbgate-plugin-mssql/package.json +++ b/plugins/dbgate-plugin-mssql/package.json @@ -32,7 +32,7 @@ }, "devDependencies": { "dbgate-plugin-tools": "^1.0.7", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "webpack": "^4.42.0", "webpack-cli": "^3.3.11", "dbgate-tools": "^5.0.0-alpha.1", diff --git a/plugins/dbgate-plugin-mssql/src/frontend/driver.js b/plugins/dbgate-plugin-mssql/src/frontend/driver.js index 14711e1f..ae1b15c7 100644 --- a/plugins/dbgate-plugin-mssql/src/frontend/driver.js +++ b/plugins/dbgate-plugin-mssql/src/frontend/driver.js @@ -130,7 +130,10 @@ const driver = { (field == 'trustServerCertificate' && values.authType != 'sql' && values.authType != 'sspi') || (field == 'windowsDomain' && values.authType != 'sql' && values.authType != 'sspi'), // (field == 'useDatabaseUrl' && values.authType != 'sql' && values.authType != 'sspi') - getQuerySplitterOptions: () => mssqlSplitterOptions, + getQuerySplitterOptions: usage => + usage == 'editor' + ? { ...mssqlSplitterOptions, adaptiveGoSplit: true, ignoreComments: true, preventSingleLineSplit: true } + : mssqlSplitterOptions, engine: 'mssql@dbgate-plugin-mssql', title: 'Microsoft SQL Server', diff --git a/plugins/dbgate-plugin-mysql/package.json b/plugins/dbgate-plugin-mysql/package.json index ca737a52..c9c9dfaf 100644 --- a/plugins/dbgate-plugin-mysql/package.json +++ b/plugins/dbgate-plugin-mysql/package.json @@ -33,7 +33,7 @@ "devDependencies": { "antares-mysql-dumper": "^0.0.1", "dbgate-plugin-tools": "^1.0.7", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "dbgate-tools": "^5.0.0-alpha.1", "mysql2": "^2.3.3", "webpack": "^4.42.0", diff --git a/plugins/dbgate-plugin-mysql/src/frontend/drivers.js b/plugins/dbgate-plugin-mysql/src/frontend/drivers.js index b9a840fe..3762fdf9 100644 --- a/plugins/dbgate-plugin-mysql/src/frontend/drivers.js +++ b/plugins/dbgate-plugin-mysql/src/frontend/drivers.js @@ -108,7 +108,11 @@ const mysqlDriverBase = { dumperClass: Dumper, dialect, defaultPort: 3306, - getQuerySplitterOptions: () => mysqlSplitterOptions, + getQuerySplitterOptions: usage => + usage == 'editor' + ? { ...mysqlSplitterOptions, ignoreComments: true, preventSingleLineSplit: true } + : mysqlSplitterOptions, + readOnlySessions: true, supportsDatabaseDump: true, authTypeLabel: 'Connection mode', diff --git a/plugins/dbgate-plugin-postgres/package.json b/plugins/dbgate-plugin-postgres/package.json index 74e9fb6a..373fe2d5 100644 --- a/plugins/dbgate-plugin-postgres/package.json +++ b/plugins/dbgate-plugin-postgres/package.json @@ -31,7 +31,7 @@ }, "devDependencies": { "dbgate-plugin-tools": "^1.0.7", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "dbgate-tools": "^5.0.0-alpha.1", "lodash": "^4.17.21", "pg": "^8.7.1", diff --git a/plugins/dbgate-plugin-postgres/src/frontend/drivers.js b/plugins/dbgate-plugin-postgres/src/frontend/drivers.js index 601a67aa..fe1c8887 100644 --- a/plugins/dbgate-plugin-postgres/src/frontend/drivers.js +++ b/plugins/dbgate-plugin-postgres/src/frontend/drivers.js @@ -105,7 +105,10 @@ const postgresDriverBase = { dialect, // showConnectionField: (field, values) => // ['server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase'].includes(field), - getQuerySplitterOptions: () => postgreSplitterOptions, + getQuerySplitterOptions: usage => + usage == 'editor' + ? { ...postgreSplitterOptions, ignoreComments: true, preventSingleLineSplit: true } + : postgreSplitterOptions, readOnlySessions: true, databaseUrlPlaceholder: 'e.g. postgresql://user:password@localhost:5432/default_database', diff --git a/plugins/dbgate-plugin-redis/package.json b/plugins/dbgate-plugin-redis/package.json index c60df74c..97a5c0e9 100644 --- a/plugins/dbgate-plugin-redis/package.json +++ b/plugins/dbgate-plugin-redis/package.json @@ -30,7 +30,7 @@ }, "devDependencies": { "dbgate-plugin-tools": "^1.0.7", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "dbgate-tools": "^5.0.0-alpha.1", "lodash": "^4.17.21", "webpack": "^4.42.0", diff --git a/plugins/dbgate-plugin-sqlite/package.json b/plugins/dbgate-plugin-sqlite/package.json index c82f057c..ded9e454 100644 --- a/plugins/dbgate-plugin-sqlite/package.json +++ b/plugins/dbgate-plugin-sqlite/package.json @@ -32,7 +32,7 @@ "devDependencies": { "dbgate-tools": "^5.0.0-alpha.1", "dbgate-plugin-tools": "^1.0.4", - "dbgate-query-splitter": "^4.9.0", + "dbgate-query-splitter": "^4.9.2", "byline": "^5.0.0", "webpack": "^4.42.0", "webpack-cli": "^3.3.11" diff --git a/plugins/dbgate-plugin-sqlite/src/frontend/driver.js b/plugins/dbgate-plugin-sqlite/src/frontend/driver.js index b1b99b2f..8632d13c 100644 --- a/plugins/dbgate-plugin-sqlite/src/frontend/driver.js +++ b/plugins/dbgate-plugin-sqlite/src/frontend/driver.js @@ -50,7 +50,14 @@ const driver = { singleDatabase: true, defaultDatabase: getDatabaseFileLabel(connection.databaseFile), }), - getQuerySplitterOptions: (usage) => (usage == 'stream' ? noSplitSplitterOptions : sqliteSplitterOptions), + + getQuerySplitterOptions: (usage) => + usage == 'editor' + ? { ...sqliteSplitterOptions, ignoreComments: true, preventSingleLineSplit: true } + : usage == 'stream' + ? noSplitSplitterOptions + : sqliteSplitterOptions, + // isFileDatabase: true, isElectronOnly: true, diff --git a/yarn.lock b/yarn.lock index ab0384f0..f5a01b77 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3309,10 +3309,10 @@ dbgate-plugin-xml@^5.0.0-alpha.1: resolved "https://registry.yarnpkg.com/dbgate-plugin-xml/-/dbgate-plugin-xml-5.0.9.tgz#c3abf6ed8cd1450c45058d35c9326458833ed27e" integrity sha512-P8Em1A6HhF0BfxEDDEUyzdgFeJHEC5vbg12frANpWHjO3V1HGdygsT2z1ukLK8FS5BLW/vcCdOFldXZGh+wWvg== -dbgate-query-splitter@^4.9.0: - version "4.9.0" - resolved "https://registry.yarnpkg.com/dbgate-query-splitter/-/dbgate-query-splitter-4.9.0.tgz#37475929b76ebe60436fcc44f223d4d47d6483af" - integrity sha512-POifNiMDkeksA9YXaC82u5O6krYC21xyROoNjDh3ouKI4xeB37DG+cP/D4IdICWHYZudlgKiziQ4v3W+5+O1DA== +dbgate-query-splitter@^4.9.2: + version "4.9.2" + resolved "https://registry.yarnpkg.com/dbgate-query-splitter/-/dbgate-query-splitter-4.9.2.tgz#ab1a60e60887ca750dd263a59db66e82c6461a46" + integrity sha512-MwZzNNLILdUv8rg6mFysLizIEdZsLLHEOL4lAHrvLPtHaLOAb275ogtgieLqjcnsXkPlV03i2t1b697aQYdfLQ== debug@2.6.9, debug@^2.2.0, debug@^2.3.3: version "2.6.9"