Import from mysql
This commit is contained in:
parent
1d1dde27e7
commit
0a108fc33a
@ -35,7 +35,7 @@ export default function TablesContextProvider({ children }) {
|
|||||||
fields: [
|
fields: [
|
||||||
{
|
{
|
||||||
name: "id",
|
name: "id",
|
||||||
type: "INT",
|
type: "INTEGER",
|
||||||
default: "",
|
default: "",
|
||||||
check: "",
|
check: "",
|
||||||
primary: true,
|
primary: true,
|
||||||
|
@ -901,7 +901,7 @@ export const mariadbTypes = {
|
|||||||
|
|
||||||
export const mssqlTypes = {
|
export const mssqlTypes = {
|
||||||
BIGINT: { type: "", checkDefault: (field) => {} },
|
BIGINT: { type: "", checkDefault: (field) => {} },
|
||||||
INT: { type: "", checkDefault: (field) => {} },
|
INTEGER: { type: "", checkDefault: (field) => {} },
|
||||||
SMALLINT: { type: "", checkDefault: (field) => {} },
|
SMALLINT: { type: "", checkDefault: (field) => {} },
|
||||||
TINYINT: { type: "", checkDefault: (field) => {} },
|
TINYINT: { type: "", checkDefault: (field) => {} },
|
||||||
BIT: { type: "", checkDefault: (field) => {} },
|
BIT: { type: "", checkDefault: (field) => {} },
|
||||||
|
@ -1,7 +1,12 @@
|
|||||||
import { Cardinality, DB } from "../../data/constants";
|
import { Cardinality, DB } from "../../data/constants";
|
||||||
|
import { dbToTypes } from "../../data/datatypes";
|
||||||
import { buildSQLFromAST } from "./shared";
|
import { buildSQLFromAST } from "./shared";
|
||||||
|
|
||||||
// eslint-disable-next-line no-unused-vars
|
export const affinity = new Proxy(
|
||||||
|
{ INT: "INTEGER" },
|
||||||
|
{ get: (target, prop) => (prop in target ? target[prop] : "BLOB") },
|
||||||
|
);
|
||||||
|
|
||||||
export function fromMySQL(ast, diagramDb = DB.GENERIC) {
|
export function fromMySQL(ast, diagramDb = DB.GENERIC) {
|
||||||
const tables = [];
|
const tables = [];
|
||||||
const relationships = [];
|
const relationships = [];
|
||||||
@ -20,7 +25,13 @@ export function fromMySQL(ast, diagramDb = DB.GENERIC) {
|
|||||||
if (d.resource === "column") {
|
if (d.resource === "column") {
|
||||||
const field = {};
|
const field = {};
|
||||||
field.name = d.column.column;
|
field.name = d.column.column;
|
||||||
field.type = d.definition.dataType;
|
|
||||||
|
let type = d.definition.dataType;
|
||||||
|
if (!dbToTypes[diagramDb][type]) {
|
||||||
|
type = affinity[type];
|
||||||
|
}
|
||||||
|
field.type = type;
|
||||||
|
|
||||||
if (d.definition.expr && d.definition.expr.type === "expr_list") {
|
if (d.definition.expr && d.definition.expr.type === "expr_list") {
|
||||||
field.values = d.definition.expr.value.map((v) => v.value);
|
field.values = d.definition.expr.value.map((v) => v.value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user