Return types after import
This commit is contained in:
parent
9e2684e7a9
commit
d79b0c205d
@ -138,14 +138,18 @@ export default function Modal({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const d = importSQL(ast, database === DB.GENERIC ? importDb : database, database);
|
const d = importSQL(
|
||||||
|
ast,
|
||||||
|
database === DB.GENERIC ? importDb : database,
|
||||||
|
database,
|
||||||
|
);
|
||||||
if (importSource.overwrite) {
|
if (importSource.overwrite) {
|
||||||
setTables(d.tables);
|
setTables(d.tables);
|
||||||
setRelationships(d.relationships);
|
setRelationships(d.relationships);
|
||||||
setTransform((prev) => ({ ...prev, pan: { x: 0, y: 0 } }));
|
setTransform((prev) => ({ ...prev, pan: { x: 0, y: 0 } }));
|
||||||
setNotes([]);
|
setNotes([]);
|
||||||
setAreas([]);
|
setAreas([]);
|
||||||
setTypes([]);
|
setTypes(d.types ?? []);
|
||||||
setUndoStack([]);
|
setUndoStack([]);
|
||||||
setRedoStack([]);
|
setRedoStack([]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -355,7 +355,7 @@ export default function WorkSpace() {
|
|||||||
okButtonProps={{ disabled: selectedDb === "" }}
|
okButtonProps={{ disabled: selectedDb === "" }}
|
||||||
>
|
>
|
||||||
<div className="grid grid-cols-3 gap-4 place-content-center">
|
<div className="grid grid-cols-3 gap-4 place-content-center">
|
||||||
{databases.map((x) => (
|
{Object.values(databases).map((x) => (
|
||||||
<div
|
<div
|
||||||
key={x.name}
|
key={x.name}
|
||||||
onClick={() => setSelectedDb(x.label)}
|
onClick={() => setSelectedDb(x.label)}
|
||||||
|
@ -6,36 +6,42 @@ import mssqlImage from "../assets/mssql-icon.png";
|
|||||||
import i18n from "../i18n/i18n";
|
import i18n from "../i18n/i18n";
|
||||||
import { DB } from "./constants";
|
import { DB } from "./constants";
|
||||||
|
|
||||||
export const databases = [
|
export const databases = {
|
||||||
{
|
[DB.MYSQL]: {
|
||||||
name: "MySQL",
|
name: "MySQL",
|
||||||
label: DB.MYSQL,
|
label: DB.MYSQL,
|
||||||
image: mysqlImage,
|
image: mysqlImage,
|
||||||
|
hasTypes: false,
|
||||||
},
|
},
|
||||||
{
|
[DB.POSTGRES]: {
|
||||||
name: "PostgreSQL",
|
name: "PostgreSQL",
|
||||||
label: DB.POSTGRES,
|
label: DB.POSTGRES,
|
||||||
image: postgresImage,
|
image: postgresImage,
|
||||||
|
hasTypes: true,
|
||||||
},
|
},
|
||||||
{
|
[DB.SQLITE]: {
|
||||||
name: "SQLite",
|
name: "SQLite",
|
||||||
label: DB.SQLITE,
|
label: DB.SQLITE,
|
||||||
image: sqliteImage,
|
image: sqliteImage,
|
||||||
|
hasTypes: false,
|
||||||
},
|
},
|
||||||
{
|
[DB.MARIADB]: {
|
||||||
name: "MariaDB",
|
name: "MariaDB",
|
||||||
label: DB.MARIADB,
|
label: DB.MARIADB,
|
||||||
image: mariadbImage,
|
image: mariadbImage,
|
||||||
|
hasTypes: false,
|
||||||
},
|
},
|
||||||
{
|
[DB.MSSQL]: {
|
||||||
name: "MSSQL",
|
name: "MSSQL",
|
||||||
label: DB.MSSQL,
|
label: DB.MSSQL,
|
||||||
image: mssqlImage,
|
image: mssqlImage,
|
||||||
|
hasTypes: false,
|
||||||
},
|
},
|
||||||
{
|
[DB.GENERIC]: {
|
||||||
name: i18n.t("generic"),
|
name: i18n.t("generic"),
|
||||||
label: DB.GENERIC,
|
label: DB.GENERIC,
|
||||||
image: null,
|
image: null,
|
||||||
description: i18n.t("generic_description"),
|
description: i18n.t("generic_description"),
|
||||||
|
hasTypes: true,
|
||||||
},
|
},
|
||||||
];
|
};
|
||||||
|
@ -10,7 +10,7 @@ import { fromPostgres } from "./postgres";
|
|||||||
import { fromSQLite } from "./sqlite";
|
import { fromSQLite } from "./sqlite";
|
||||||
|
|
||||||
export function importSQL(ast, toDb = DB.MYSQL, diagramDb = DB.GENERIC) {
|
export function importSQL(ast, toDb = DB.MYSQL, diagramDb = DB.GENERIC) {
|
||||||
let diagram = { tables: [], relationships: [] };
|
let diagram;
|
||||||
switch (toDb) {
|
switch (toDb) {
|
||||||
case DB.SQLITE:
|
case DB.SQLITE:
|
||||||
diagram = fromSQLite(ast, diagramDb);
|
diagram = fromSQLite(ast, diagramDb);
|
||||||
|
@ -20,6 +20,7 @@ const affinity = {
|
|||||||
export function fromPostgres(ast, diagramDb = DB.GENERIC) {
|
export function fromPostgres(ast, diagramDb = DB.GENERIC) {
|
||||||
const tables = [];
|
const tables = [];
|
||||||
const relationships = [];
|
const relationships = [];
|
||||||
|
const types = [];
|
||||||
|
|
||||||
ast.forEach((e) => {
|
ast.forEach((e) => {
|
||||||
if (e.type === "create") {
|
if (e.type === "create") {
|
||||||
@ -241,5 +242,5 @@ export function fromPostgres(ast, diagramDb = DB.GENERIC) {
|
|||||||
|
|
||||||
relationships.forEach((r, i) => (r.id = i));
|
relationships.forEach((r, i) => (r.id = i));
|
||||||
|
|
||||||
return { tables, relationships };
|
return { tables, relationships, types };
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user