show create view

This commit is contained in:
Jan Prochazka
2020-04-12 18:55:47 +02:00
parent 4bc252fdd2
commit 99a9b003bc
5 changed files with 18 additions and 4 deletions

View File

@@ -247,7 +247,7 @@ class MsSqlAnalyser extends DatabaseAnalayser {
...row, ...row,
createSql: getCreateSql(row), createSql: getCreateSql(row),
columns: viewColumnRows.rows columns: viewColumnRows.rows
.filter((col) => (col.objectId = row.objectId)) .filter((col) => col.objectId == row.objectId)
.map(({ isNullable, isIdentity, ...col }) => ({ .map(({ isNullable, isIdentity, ...col }) => ({
...col, ...col,
notNull: !isNullable, notNull: !isNullable,

View File

@@ -41,7 +41,7 @@ function Menu({ data, makeAppObj, setOpenedTabs }) {
<> <>
<DropDownMenuItem onClick={handleOpenData}>Open data</DropDownMenuItem> <DropDownMenuItem onClick={handleOpenData}>Open data</DropDownMenuItem>
<DropDownMenuItem onClick={handleOpenStructure}>Open structure</DropDownMenuItem> <DropDownMenuItem onClick={handleOpenStructure}>Open structure</DropDownMenuItem>
<DropDownMenuItem onClick={handleOpenCreateScript}>Create SQL</DropDownMenuItem> <DropDownMenuItem onClick={handleOpenCreateScript}>Show CREATE TABLE script</DropDownMenuItem>
</> </>
); );
} }

View File

@@ -32,12 +32,12 @@ function Menu({ data, makeAppObj, setOpenedTabs }) {
openViewDetail(setOpenedTabs, 'TableDataTab', data); openViewDetail(setOpenedTabs, 'TableDataTab', data);
}; };
const handleOpenCreateScript = () => { const handleOpenCreateScript = () => {
openViewDetail(setOpenedTabs, 'TableCreateScriptTab', data); openViewDetail(setOpenedTabs, 'ViewCreateScriptTab', data);
}; };
return ( return (
<> <>
<DropDownMenuItem onClick={handleOpenData}>Open data</DropDownMenuItem> <DropDownMenuItem onClick={handleOpenData}>Open data</DropDownMenuItem>
<DropDownMenuItem onClick={handleOpenCreateScript}>Create SQL</DropDownMenuItem> <DropDownMenuItem onClick={handleOpenCreateScript}>Show CREATE VIEW script</DropDownMenuItem>
</> </>
); );
} }

View File

@@ -0,0 +1,12 @@
import React from 'react';
import useConnectionInfo from '../utility/useConnectionInfo';
import SqlEditor from '../sqleditor/SqlEditor';
import useViewInfo from '../utility/useViewInfo';
export default function ViewCreateScriptTab({ conid, database, schemaName, pureName }) {
const viewInfo = useViewInfo({ conid, database, schemaName, pureName });
const connnection = useConnectionInfo(conid);
if (!connnection || !viewInfo) return null;
return <SqlEditor engine={connnection && connnection.engine} value={viewInfo.createSql} readOnly />;
}

View File

@@ -2,6 +2,7 @@ import TableDataTab from './TableDataTab';
import ViewDataTab from './ViewDataTab'; import ViewDataTab from './ViewDataTab';
import TableStructureTab from './TableStructureTab'; import TableStructureTab from './TableStructureTab';
import TableCreateScriptTab from './TableCreateScriptTab'; import TableCreateScriptTab from './TableCreateScriptTab';
import ViewCreateScriptTab from './ViewCreateScriptTab';
import QueryTab from './QueryTab'; import QueryTab from './QueryTab';
export default { export default {
@@ -10,4 +11,5 @@ export default {
TableStructureTab, TableStructureTab,
TableCreateScriptTab, TableCreateScriptTab,
QueryTab, QueryTab,
ViewCreateScriptTab,
}; };