mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-17 22:36:01 +00:00
show create view
This commit is contained in:
@@ -247,7 +247,7 @@ class MsSqlAnalyser extends DatabaseAnalayser {
|
||||
...row,
|
||||
createSql: getCreateSql(row),
|
||||
columns: viewColumnRows.rows
|
||||
.filter((col) => (col.objectId = row.objectId))
|
||||
.filter((col) => col.objectId == row.objectId)
|
||||
.map(({ isNullable, isIdentity, ...col }) => ({
|
||||
...col,
|
||||
notNull: !isNullable,
|
||||
|
||||
@@ -41,7 +41,7 @@ function Menu({ data, makeAppObj, setOpenedTabs }) {
|
||||
<>
|
||||
<DropDownMenuItem onClick={handleOpenData}>Open data</DropDownMenuItem>
|
||||
<DropDownMenuItem onClick={handleOpenStructure}>Open structure</DropDownMenuItem>
|
||||
<DropDownMenuItem onClick={handleOpenCreateScript}>Create SQL</DropDownMenuItem>
|
||||
<DropDownMenuItem onClick={handleOpenCreateScript}>Show CREATE TABLE script</DropDownMenuItem>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -32,12 +32,12 @@ function Menu({ data, makeAppObj, setOpenedTabs }) {
|
||||
openViewDetail(setOpenedTabs, 'TableDataTab', data);
|
||||
};
|
||||
const handleOpenCreateScript = () => {
|
||||
openViewDetail(setOpenedTabs, 'TableCreateScriptTab', data);
|
||||
openViewDetail(setOpenedTabs, 'ViewCreateScriptTab', data);
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<DropDownMenuItem onClick={handleOpenData}>Open data</DropDownMenuItem>
|
||||
<DropDownMenuItem onClick={handleOpenCreateScript}>Create SQL</DropDownMenuItem>
|
||||
<DropDownMenuItem onClick={handleOpenCreateScript}>Show CREATE VIEW script</DropDownMenuItem>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
12
packages/web/src/tabs/ViewCreateScriptTab.js
Normal file
12
packages/web/src/tabs/ViewCreateScriptTab.js
Normal 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 />;
|
||||
}
|
||||
@@ -2,6 +2,7 @@ import TableDataTab from './TableDataTab';
|
||||
import ViewDataTab from './ViewDataTab';
|
||||
import TableStructureTab from './TableStructureTab';
|
||||
import TableCreateScriptTab from './TableCreateScriptTab';
|
||||
import ViewCreateScriptTab from './ViewCreateScriptTab';
|
||||
import QueryTab from './QueryTab';
|
||||
|
||||
export default {
|
||||
@@ -10,4 +11,5 @@ export default {
|
||||
TableStructureTab,
|
||||
TableCreateScriptTab,
|
||||
QueryTab,
|
||||
ViewCreateScriptTab,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user