mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-05-01 12:03:58 +00:00
show create view
This commit is contained in:
@@ -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,
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
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 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,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user