better editor SQL splitting

This commit is contained in:
Jan Prochazka
2022-09-28 12:24:06 +02:00
parent 8ce5e68c0d
commit c5a7f458ba
17 changed files with 39 additions and 24 deletions

View File

@@ -25,7 +25,7 @@
"compare-versions": "^3.6.0", "compare-versions": "^3.6.0",
"cors": "^2.8.5", "cors": "^2.8.5",
"cross-env": "^6.0.3", "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-sqltree": "^5.0.0-alpha.1",
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",
"debug": "^4.3.4", "debug": "^4.3.4",

View File

@@ -47,7 +47,7 @@ async function importDatabase({ connection = undefined, systemConnection = undef
const downloadedFile = await download(inputFile); const downloadedFile = await download(inputFile);
const fileStream = fs.createReadStream(downloadedFile, 'utf-8'); 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); const importStream = new ImportStream(pool, driver);
// @ts-ignore // @ts-ignore
splittedStream.pipe(importStream); splittedStream.pipe(importStream);

View File

@@ -31,7 +31,7 @@
"typescript": "^4.4.3" "typescript": "^4.4.3"
}, },
"dependencies": { "dependencies": {
"dbgate-query-splitter": "^4.9.0", "dbgate-query-splitter": "^4.9.2",
"dbgate-sqltree": "^5.0.0-alpha.1", "dbgate-sqltree": "^5.0.0-alpha.1",
"debug": "^4.3.4", "debug": "^4.3.4",
"json-stable-stringify": "^1.0.1", "json-stable-stringify": "^1.0.1",

View File

@@ -89,9 +89,7 @@ export interface EngineDriver {
): Promise<TableInfo | ViewInfo | ProcedureInfo | FunctionInfo | TriggerInfo>; ): Promise<TableInfo | ViewInfo | ProcedureInfo | FunctionInfo | TriggerInfo>;
analyseSingleTable(pool: any, name: NamedObjectInfo): Promise<TableInfo>; analyseSingleTable(pool: any, name: NamedObjectInfo): Promise<TableInfo>;
getVersion(pool: any): Promise<{ version: string }>; getVersion(pool: any): Promise<{ version: string }>;
listDatabases( listDatabases(pool: any): Promise<
pool: any
): Promise<
{ {
name: string; name: string;
}[] }[]
@@ -112,7 +110,7 @@ export interface EngineDriver {
updateCollection(pool: any, changeSet: any): Promise<any>; updateCollection(pool: any, changeSet: any): Promise<any>;
getCollectionUpdateScript(changeSet: any): string; getCollectionUpdateScript(changeSet: any): string;
createDatabase(pool: any, name: string): Promise; createDatabase(pool: any, name: string): Promise;
getQuerySplitterOptions(usage: 'stream' | 'script'): any; getQuerySplitterOptions(usage: 'stream' | 'script' | 'editor'): any;
script(pool: any, sql: string): Promise; script(pool: any, sql: string): Promise;
getNewObjectTemplates(): NewObjectTemplate[]; getNewObjectTemplates(): NewObjectTemplate[];
// direct call of pool method, only some methods could be supported, on only some drivers // direct call of pool method, only some methods could be supported, on only some drivers

View File

@@ -24,7 +24,7 @@
"chartjs-adapter-moment": "^1.0.0", "chartjs-adapter-moment": "^1.0.0",
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"dbgate-datalib": "^5.0.0-alpha.1", "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-sqltree": "^5.0.0-alpha.1",
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",
"dbgate-types": "^5.0.0-alpha.1", "dbgate-types": "^5.0.0-alpha.1",

View File

@@ -293,7 +293,7 @@
engine={$connection && $connection.engine} engine={$connection && $connection.engine}
{conid} {conid}
{database} {database}
splitterOptions={driver?.getQuerySplitterOptions('script')} splitterOptions={driver?.getQuerySplitterOptions('editor')}
value={$editorState.value || ''} value={$editorState.value || ''}
menu={createMenu()} menu={createMenu()}
on:input={e => { on:input={e => {
@@ -312,7 +312,7 @@
<AceEditor <AceEditor
mode={driver?.editorMode || 'text'} mode={driver?.editorMode || 'text'}
value={$editorState.value || ''} value={$editorState.value || ''}
splitterOptions={driver?.getQuerySplitterOptions('script')} splitterOptions={driver?.getQuerySplitterOptions('editor')}
menu={createMenu()} menu={createMenu()}
on:input={e => setEditorData(e.detail)} on:input={e => setEditorData(e.detail)}
on:focus={() => { on:focus={() => {

View File

@@ -32,7 +32,7 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"dbgate-query-splitter": "^4.9.0", "dbgate-query-splitter": "^4.9.2",
"webpack": "^4.42.0", "webpack": "^4.42.0",
"webpack-cli": "^3.3.11", "webpack-cli": "^3.3.11",
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",

View File

@@ -32,7 +32,7 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.7", "dbgate-plugin-tools": "^1.0.7",
"dbgate-query-splitter": "^4.9.0", "dbgate-query-splitter": "^4.9.2",
"webpack": "^4.42.0", "webpack": "^4.42.0",
"webpack-cli": "^3.3.11", "webpack-cli": "^3.3.11",
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",

View File

@@ -130,7 +130,10 @@ const driver = {
(field == 'trustServerCertificate' && values.authType != 'sql' && values.authType != 'sspi') || (field == 'trustServerCertificate' && values.authType != 'sql' && values.authType != 'sspi') ||
(field == 'windowsDomain' && values.authType != 'sql' && values.authType != 'sspi'), (field == 'windowsDomain' && values.authType != 'sql' && values.authType != 'sspi'),
// (field == 'useDatabaseUrl' && 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', engine: 'mssql@dbgate-plugin-mssql',
title: 'Microsoft SQL Server', title: 'Microsoft SQL Server',

View File

@@ -33,7 +33,7 @@
"devDependencies": { "devDependencies": {
"antares-mysql-dumper": "^0.0.1", "antares-mysql-dumper": "^0.0.1",
"dbgate-plugin-tools": "^1.0.7", "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", "dbgate-tools": "^5.0.0-alpha.1",
"mysql2": "^2.3.3", "mysql2": "^2.3.3",
"webpack": "^4.42.0", "webpack": "^4.42.0",

View File

@@ -108,7 +108,11 @@ const mysqlDriverBase = {
dumperClass: Dumper, dumperClass: Dumper,
dialect, dialect,
defaultPort: 3306, defaultPort: 3306,
getQuerySplitterOptions: () => mysqlSplitterOptions, getQuerySplitterOptions: usage =>
usage == 'editor'
? { ...mysqlSplitterOptions, ignoreComments: true, preventSingleLineSplit: true }
: mysqlSplitterOptions,
readOnlySessions: true, readOnlySessions: true,
supportsDatabaseDump: true, supportsDatabaseDump: true,
authTypeLabel: 'Connection mode', authTypeLabel: 'Connection mode',

View File

@@ -31,7 +31,7 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.7", "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", "dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"pg": "^8.7.1", "pg": "^8.7.1",

View File

@@ -105,7 +105,10 @@ const postgresDriverBase = {
dialect, dialect,
// showConnectionField: (field, values) => // showConnectionField: (field, values) =>
// ['server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase'].includes(field), // ['server', 'port', 'user', 'password', 'defaultDatabase', 'singleDatabase'].includes(field),
getQuerySplitterOptions: () => postgreSplitterOptions, getQuerySplitterOptions: usage =>
usage == 'editor'
? { ...postgreSplitterOptions, ignoreComments: true, preventSingleLineSplit: true }
: postgreSplitterOptions,
readOnlySessions: true, readOnlySessions: true,
databaseUrlPlaceholder: 'e.g. postgresql://user:password@localhost:5432/default_database', databaseUrlPlaceholder: 'e.g. postgresql://user:password@localhost:5432/default_database',

View File

@@ -30,7 +30,7 @@
}, },
"devDependencies": { "devDependencies": {
"dbgate-plugin-tools": "^1.0.7", "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", "dbgate-tools": "^5.0.0-alpha.1",
"lodash": "^4.17.21", "lodash": "^4.17.21",
"webpack": "^4.42.0", "webpack": "^4.42.0",

View File

@@ -32,7 +32,7 @@
"devDependencies": { "devDependencies": {
"dbgate-tools": "^5.0.0-alpha.1", "dbgate-tools": "^5.0.0-alpha.1",
"dbgate-plugin-tools": "^1.0.4", "dbgate-plugin-tools": "^1.0.4",
"dbgate-query-splitter": "^4.9.0", "dbgate-query-splitter": "^4.9.2",
"byline": "^5.0.0", "byline": "^5.0.0",
"webpack": "^4.42.0", "webpack": "^4.42.0",
"webpack-cli": "^3.3.11" "webpack-cli": "^3.3.11"

View File

@@ -50,7 +50,14 @@ const driver = {
singleDatabase: true, singleDatabase: true,
defaultDatabase: getDatabaseFileLabel(connection.databaseFile), 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, // isFileDatabase: true,
isElectronOnly: true, isElectronOnly: true,

View File

@@ -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" resolved "https://registry.yarnpkg.com/dbgate-plugin-xml/-/dbgate-plugin-xml-5.0.9.tgz#c3abf6ed8cd1450c45058d35c9326458833ed27e"
integrity sha512-P8Em1A6HhF0BfxEDDEUyzdgFeJHEC5vbg12frANpWHjO3V1HGdygsT2z1ukLK8FS5BLW/vcCdOFldXZGh+wWvg== integrity sha512-P8Em1A6HhF0BfxEDDEUyzdgFeJHEC5vbg12frANpWHjO3V1HGdygsT2z1ukLK8FS5BLW/vcCdOFldXZGh+wWvg==
dbgate-query-splitter@^4.9.0: dbgate-query-splitter@^4.9.2:
version "4.9.0" version "4.9.2"
resolved "https://registry.yarnpkg.com/dbgate-query-splitter/-/dbgate-query-splitter-4.9.0.tgz#37475929b76ebe60436fcc44f223d4d47d6483af" resolved "https://registry.yarnpkg.com/dbgate-query-splitter/-/dbgate-query-splitter-4.9.2.tgz#ab1a60e60887ca750dd263a59db66e82c6461a46"
integrity sha512-POifNiMDkeksA9YXaC82u5O6krYC21xyROoNjDh3ouKI4xeB37DG+cP/D4IdICWHYZudlgKiziQ4v3W+5+O1DA== integrity sha512-MwZzNNLILdUv8rg6mFysLizIEdZsLLHEOL4lAHrvLPtHaLOAb275ogtgieLqjcnsXkPlV03i2t1b697aQYdfLQ==
debug@2.6.9, debug@^2.2.0, debug@^2.3.3: debug@2.6.9, debug@^2.2.0, debug@^2.3.3:
version "2.6.9" version "2.6.9"