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