sql generator

This commit is contained in:
Jan Prochazka
2021-04-01 08:27:58 +02:00
parent d62177d996
commit f146d70e2b
2 changed files with 85 additions and 0 deletions

View File

@@ -65,6 +65,27 @@
label: 'SQL: SELECT',
sqlTemplate: 'SELECT',
},
{
label: 'SQL Generator: CREATE TABLE',
sqlGeneratorProps: {
createTables: true,
createIndexes: true,
createForeignKeys: true,
},
},
{
label: 'SQL Generator: DROP TABLE',
sqlGeneratorProps: {
dropTables: true,
dropReferences: true,
},
},
{
label: 'SQL Generator: INSERT',
sqlGeneratorProps: {
insert: true,
},
},
],
views: [
{
@@ -110,6 +131,18 @@
label: 'SQL: SELECT',
sqlTemplate: 'SELECT',
},
{
label: 'SQL Generator: CREATE VIEW',
sqlGeneratorProps: {
createViews: true,
},
},
{
label: 'SQL Generator: DROP VIEW',
sqlGeneratorProps: {
dropViews: true,
},
},
],
procedures: [
{
@@ -120,12 +153,36 @@
label: 'SQL: EXECUTE',
sqlTemplate: 'EXECUTE PROCEDURE',
},
{
label: 'SQL Generator: CREATE PROCEDURE',
sqlGeneratorProps: {
createProcedures: true,
},
},
{
label: 'SQL Generator: DROP PROCEDURE',
sqlGeneratorProps: {
dropProcedures: true,
},
},
],
functions: [
{
label: 'SQL: CREATE FUNCTION',
sqlTemplate: 'CREATE OBJECT',
},
{
label: 'SQL Generator: CREATE FUNCTION',
sqlGeneratorProps: {
createFunctions: true,
},
},
{
label: 'SQL Generator: DROP FUNCTION',
sqlGeneratorProps: {
dropFunctions: true,
},
},
],
};
@@ -175,6 +232,7 @@
import { showModal } from '../modals/modalTools';
import { findEngineDriver } from 'dbgate-tools';
import uuidv1 from 'uuid/v1';
import SqlGeneratorModal from '../modals/SqlGeneratorModal.svelte';
export let data;
@@ -298,6 +356,13 @@
},
}
);
} else if (menu.sqlGeneratorProps) {
showModal(SqlGeneratorModal, {
initialObjects: [data],
initialConfig: menu.sqlGeneratorProps,
conid: data.conid,
database: data.database,
});
} else {
openDatabaseObjectDetail(menu.tab, menu.sqlTemplate, data, menu.forceNewTab, menu.initialData);
}

View File

@@ -28,6 +28,7 @@
import ModalBase from './ModalBase.svelte';
import { closeCurrentModal } from './modalTools';
import WidgetTitle from '../widgets/WidgetTitle.svelte';
import openNewTab from '../utility/openNewTab';
export let conid;
export let database;
@@ -94,6 +95,24 @@
}
busy = false;
}
function editSql() {
openNewTab(
{
title: 'Query #',
icon: 'img sql-file',
tabComponent: 'QueryTab',
props: {
conid,
database,
},
},
{
editor: sqlPreview,
}
);
closeCurrentModal();
}
</script>
<FormProviderCore values={valuesStore} template={FormFieldTemplateTiny}>
@@ -187,6 +206,7 @@
<svelte:fragment slot="footer">
<div class="flex m-2">
<LargeButton on:click={editSql} icon="icon sql-file">Edit SQL</LargeButton>
<LargeButton on:click={closeCurrentModal} icon="icon close">Close</LargeButton>
</div>
</svelte:fragment>