Swap INTEGER for INT in generic diagrams to maintain backward compatibility
This commit is contained in:
parent
d8128f5010
commit
9e2684e7a9
@ -1,6 +1,6 @@
|
||||
import { Tabs, TabPane } from "@douyinfe/semi-ui";
|
||||
import { Tab } from "../../data/constants";
|
||||
import { useLayout, useSelect } from "../../hooks";
|
||||
import { DB, Tab } from "../../data/constants";
|
||||
import { useLayout, useSelect, useTables } from "../../hooks";
|
||||
import RelationshipsTab from "./RelationshipsTab/RelationshipsTab";
|
||||
import TypesTab from "./TypesTab/TypesTab";
|
||||
import Issues from "./Issues";
|
||||
@ -8,23 +8,34 @@ import AreasTab from "./AreasTab/AreasTab";
|
||||
import NotesTab from "./NotesTab/NotesTab";
|
||||
import TablesTab from "./TablesTab/TablesTab";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useMemo } from "react";
|
||||
|
||||
export default function SidePanel({ width, resize, setResize }) {
|
||||
const { layout } = useLayout();
|
||||
const { selectedElement, setSelectedElement } = useSelect();
|
||||
const { database } = useTables();
|
||||
const { t } = useTranslation();
|
||||
|
||||
const tabList = [
|
||||
{ tab: t("tables"), itemKey: Tab.TABLES, component: <TablesTab /> },
|
||||
{
|
||||
tab: t("relationships"),
|
||||
itemKey: Tab.RELATIONSHIPS,
|
||||
component: <RelationshipsTab />,
|
||||
},
|
||||
{ tab: t("subject_areas"), itemKey: Tab.AREAS, component: <AreasTab /> },
|
||||
{ tab: t("notes"), itemKey: Tab.NOTES, component: <NotesTab /> },
|
||||
{ tab: t("types"), itemKey: Tab.TYPES, component: <TypesTab /> },
|
||||
];
|
||||
const tabList = useMemo(() => {
|
||||
const tabs = [
|
||||
{ tab: t("tables"), itemKey: Tab.TABLES, component: <TablesTab /> },
|
||||
{
|
||||
tab: t("relationships"),
|
||||
itemKey: Tab.RELATIONSHIPS,
|
||||
component: <RelationshipsTab />,
|
||||
},
|
||||
{ tab: t("subject_areas"), itemKey: Tab.AREAS, component: <AreasTab /> },
|
||||
{ tab: t("notes"), itemKey: Tab.NOTES, component: <NotesTab /> },
|
||||
];
|
||||
if (database === DB.GENERIC || database === DB.POSTGRES) {
|
||||
tabs.push({
|
||||
tab: t("types"),
|
||||
itemKey: Tab.TYPES,
|
||||
component: <TypesTab />,
|
||||
});
|
||||
}
|
||||
return tabs;
|
||||
}, [t, database]);
|
||||
|
||||
return (
|
||||
<div className="flex h-full">
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { createContext, useState } from "react";
|
||||
import { Action, ObjectType, defaultBlue } from "../data/constants";
|
||||
import { Action, DB, ObjectType, defaultBlue } from "../data/constants";
|
||||
import useTransform from "../hooks/useTransform";
|
||||
import useUndoRedo from "../hooks/useUndoRedo";
|
||||
import useSelect from "../hooks/useSelect";
|
||||
@ -35,7 +35,7 @@ export default function TablesContextProvider({ children }) {
|
||||
fields: [
|
||||
{
|
||||
name: "id",
|
||||
type: "INTEGER",
|
||||
type: database === DB.GENERIC ? "INT" : "INTEGER",
|
||||
default: "",
|
||||
check: "",
|
||||
primary: true,
|
||||
|
@ -6,8 +6,8 @@ const binaryRegex = /^[01]+$/;
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
export const defaultTypes = {
|
||||
INTEGER: {
|
||||
type: "INTEGER",
|
||||
INT: {
|
||||
type: "INT",
|
||||
checkDefault: (field) => {
|
||||
return intRegex.test(field.default);
|
||||
},
|
||||
|
@ -151,7 +151,9 @@ export function jsonToMySQL(obj) {
|
||||
}\` ${getTypeString(field, obj.database)}${field.notNull ? " NOT NULL" : ""}${
|
||||
field.increment ? " AUTO_INCREMENT" : ""
|
||||
}${field.unique ? " UNIQUE" : ""}${
|
||||
field.default !== "" ? ` DEFAULT ${parseDefault(field, obj.database)}` : ""
|
||||
field.default !== ""
|
||||
? ` DEFAULT ${parseDefault(field, obj.database)}`
|
||||
: ""
|
||||
}${
|
||||
field.check === "" ||
|
||||
!dbToTypes[obj.database][field.type].hasCheck
|
||||
@ -250,7 +252,9 @@ export function jsonToPostgreSQL(obj) {
|
||||
}" ${getTypeString(field, obj.database, "postgres")}${
|
||||
field.notNull ? " NOT NULL" : ""
|
||||
}${
|
||||
field.default !== "" ? ` DEFAULT ${parseDefault(field, obj.database)}` : ""
|
||||
field.default !== ""
|
||||
? ` DEFAULT ${parseDefault(field, obj.database)}`
|
||||
: ""
|
||||
}${
|
||||
field.check === "" ||
|
||||
!dbToTypes[obj.database][field.type].hasCheck
|
||||
@ -397,7 +401,9 @@ export function jsonToMariaDB(obj) {
|
||||
}\` ${getTypeString(field, obj.database)}${field.notNull ? " NOT NULL" : ""}${
|
||||
field.increment ? " AUTO_INCREMENT" : ""
|
||||
}${field.unique ? " UNIQUE" : ""}${
|
||||
field.default !== "" ? ` DEFAULT ${parseDefault(field, obj.database)}` : ""
|
||||
field.default !== ""
|
||||
? ` DEFAULT ${parseDefault(field, obj.database)}`
|
||||
: ""
|
||||
}${
|
||||
field.check === "" ||
|
||||
!dbToTypes[obj.database][field.type].hasCheck
|
||||
@ -471,7 +477,9 @@ export function jsonToSQLServer(obj) {
|
||||
}${field.increment ? " IDENTITY" : ""}${
|
||||
field.unique ? " UNIQUE" : ""
|
||||
}${
|
||||
field.default !== "" ? ` DEFAULT ${parseDefault(field, obj.database)}` : ""
|
||||
field.default !== ""
|
||||
? ` DEFAULT ${parseDefault(field, obj.database)}`
|
||||
: ""
|
||||
}${
|
||||
field.check === "" ||
|
||||
!dbToTypes[obj.database][field.type].hasCheck
|
||||
|
Loading…
Reference in New Issue
Block a user