mirror of
https://github.com/dbgate/dbgate
synced 2024-11-07 20:26:23 +00:00
sql template => script template
This commit is contained in:
parent
88b4c9daff
commit
90169a7624
@ -61,11 +61,11 @@
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE TABLE',
|
||||
sqlTemplate: 'CREATE TABLE',
|
||||
scriptTemplate: 'CREATE TABLE',
|
||||
},
|
||||
{
|
||||
label: 'SQL: SELECT',
|
||||
sqlTemplate: 'SELECT',
|
||||
scriptTemplate: 'SELECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE TABLE',
|
||||
@ -123,15 +123,15 @@
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE VIEW',
|
||||
sqlTemplate: 'CREATE OBJECT',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: CREATE TABLE',
|
||||
sqlTemplate: 'CREATE TABLE',
|
||||
scriptTemplate: 'CREATE TABLE',
|
||||
},
|
||||
{
|
||||
label: 'SQL: SELECT',
|
||||
sqlTemplate: 'SELECT',
|
||||
scriptTemplate: 'SELECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE VIEW',
|
||||
@ -149,11 +149,11 @@
|
||||
procedures: [
|
||||
{
|
||||
label: 'SQL: CREATE PROCEDURE',
|
||||
sqlTemplate: 'CREATE OBJECT',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL: EXECUTE',
|
||||
sqlTemplate: 'EXECUTE PROCEDURE',
|
||||
scriptTemplate: 'EXECUTE PROCEDURE',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE PROCEDURE',
|
||||
@ -171,7 +171,7 @@
|
||||
functions: [
|
||||
{
|
||||
label: 'SQL: CREATE FUNCTION',
|
||||
sqlTemplate: 'CREATE OBJECT',
|
||||
scriptTemplate: 'CREATE OBJECT',
|
||||
},
|
||||
{
|
||||
label: 'SQL Generator: CREATE FUNCTION',
|
||||
@ -211,7 +211,7 @@
|
||||
|
||||
export async function openDatabaseObjectDetail(
|
||||
tabComponent,
|
||||
sqlTemplate,
|
||||
scriptTemplate,
|
||||
{ schemaName, pureName, conid, database, objectTypeField },
|
||||
forceNewTab,
|
||||
initialData
|
||||
@ -224,17 +224,17 @@
|
||||
|
||||
openNewTab(
|
||||
{
|
||||
title: sqlTemplate ? 'Query #' : pureName,
|
||||
title: scriptTemplate ? 'Query #' : pureName,
|
||||
tooltip,
|
||||
icon: sqlTemplate ? 'img sql-file' : icons[objectTypeField],
|
||||
tabComponent: sqlTemplate ? 'QueryTab' : tabComponent,
|
||||
icon: scriptTemplate ? 'img sql-file' : icons[objectTypeField],
|
||||
tabComponent: scriptTemplate ? 'QueryTab' : tabComponent,
|
||||
props: {
|
||||
schemaName,
|
||||
pureName,
|
||||
conid,
|
||||
database,
|
||||
objectTypeField,
|
||||
initialArgs: sqlTemplate ? { sqlTemplate } : null,
|
||||
initialArgs: scriptTemplate ? { scriptTemplate } : null,
|
||||
},
|
||||
},
|
||||
initialData,
|
||||
@ -387,7 +387,7 @@
|
||||
database: data.database,
|
||||
});
|
||||
} else {
|
||||
openDatabaseObjectDetail(menu.tab, menu.sqlTemplate, data, menu.forceNewTab, menu.initialData);
|
||||
openDatabaseObjectDetail(menu.tab, menu.scriptTemplate, data, menu.forceNewTab, menu.initialData);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
@ -40,7 +40,7 @@
|
||||
import SqlEditor from '../query/SqlEditor.svelte';
|
||||
import useEditorData from '../query/useEditorData';
|
||||
import { extensions } from '../stores';
|
||||
import applySqlTemplate from '../utility/applySqlTemplate';
|
||||
import applyScriptTemplate from '../utility/applyScriptTemplate';
|
||||
import axiosInstance from '../utility/axiosInstance';
|
||||
import { changeTab } from '../utility/common';
|
||||
import { getDatabaseInfo, useConnectionInfo } from '../utility/metadataLoaders';
|
||||
@ -207,8 +207,8 @@
|
||||
const { editorState, editorValue, setEditorData } = useEditorData({
|
||||
tabid,
|
||||
loadFromArgs:
|
||||
initialArgs && initialArgs.sqlTemplate
|
||||
? () => applySqlTemplate(initialArgs.sqlTemplate, $extensions, $$props)
|
||||
initialArgs && initialArgs.scriptTemplate
|
||||
? () => applyScriptTemplate(initialArgs.scriptTemplate, $extensions, $$props)
|
||||
: null,
|
||||
});
|
||||
|
||||
|
@ -11,11 +11,11 @@ async function generateTableSql(extensions, props, dumpProc, format = false) {
|
||||
return format ? sqlFormatter.format(dmp.s) : dmp.s;
|
||||
}
|
||||
|
||||
export default async function applySqlTemplate(sqlTemplate, extensions, props) {
|
||||
if (sqlTemplate == 'CREATE TABLE') {
|
||||
export default async function applyScriptTemplate(scriptTemplate, extensions, props) {
|
||||
if (scriptTemplate == 'CREATE TABLE') {
|
||||
return generateTableSql(extensions, props, (dmp, tableInfo) => dmp.createTable(tableInfo));
|
||||
}
|
||||
if (sqlTemplate == 'SELECT') {
|
||||
if (scriptTemplate == 'SELECT') {
|
||||
return generateTableSql(
|
||||
extensions,
|
||||
props,
|
||||
@ -29,14 +29,14 @@ export default async function applySqlTemplate(sqlTemplate, extensions, props) {
|
||||
true
|
||||
);
|
||||
}
|
||||
if (sqlTemplate == 'CREATE OBJECT') {
|
||||
if (scriptTemplate == 'CREATE OBJECT') {
|
||||
const objectInfo = await getSqlObjectInfo(props);
|
||||
if (objectInfo) {
|
||||
if (objectInfo.requiresFormat && objectInfo.createSql) return sqlFormatter.format(objectInfo.createSql);
|
||||
else return objectInfo.createSql;
|
||||
}
|
||||
}
|
||||
if (sqlTemplate == 'EXECUTE PROCEDURE') {
|
||||
if (scriptTemplate == 'EXECUTE PROCEDURE') {
|
||||
const procedureInfo = await getSqlObjectInfo(props);
|
||||
const connection = await getConnectionInfo(props);
|
||||
|
Loading…
Reference in New Issue
Block a user