Skip to content

Free, simple, and intuitive online database diagram editor and SQL generator.

fix add field

1ilit79874a0413e8
diff --git a/src/components/rect.jsx b/src/components/rect.jsx
index 849a5648..164f041e 100644
--- a/src/components/rect.jsx
+++ b/src/components/rect.jsx
@@ -1,5 +1,6 @@
import { React, useState } from "react";
import Node from "./node";
+import sqlDataTypes from "./sql_types";
import {
IconEdit,
IconDelete,
@@ -49,37 +50,19 @@ const Rect = (props) => {
};
const handleOk = () => {
- console.log(field);
setFields((prev) => [...prev, field]);
+ setField({
+ name: "",
+ type: "",
+ default: "",
+ primary: false,
+ unique: false,
+ notNull: false,
+ increment: false,
+ });
setVisible(false);
};
- const sqlDataTypes = [
- "INT",
- "SMALLINT",
- "BIGINT",
- "DECIMAL",
- "NUMERIC",
- "FLOAT",
- "REAL",
- "DOUBLE PRECISION",
- "CHAR",
- "VARCHAR",
- "TEXT",
- "DATE",
- "TIME",
- "TIMESTAMP",
- "INTERVAL",
- "BOOLEAN",
- "BINARY",
- "VARBINARY",
- "BLOB",
- "CLOB",
- "UUID",
- "XML",
- "JSON",
- ];
-
const height = fields.length * 36 + 40 + 4;
return (
@@ -303,7 +286,6 @@ const Rect = (props) => {
title="Add new field"
visible={visible}
onOk={handleOk}
- afterClose={() => {}}
onCancel={handleOk}
centered
closeOnEsc={true}
diff --git a/src/components/sql_types.js b/src/components/sql_types.js
new file mode 100644
index 00000000..aebd37c8
--- /dev/null
+++ b/src/components/sql_types.js
@@ -0,0 +1,27 @@
+const sqlDataTypes = [
+ "INT",
+ "SMALLINT",
+ "BIGINT",
+ "DECIMAL",
+ "NUMERIC",
+ "FLOAT",
+ "REAL",
+ "DOUBLE PRECISION",
+ "CHAR",
+ "VARCHAR",
+ "TEXT",
+ "DATE",
+ "TIME",
+ "TIMESTAMP",
+ "INTERVAL",
+ "BOOLEAN",
+ "BINARY",
+ "VARBINARY",
+ "BLOB",
+ "CLOB",
+ "UUID",
+ "XML",
+ "JSON",
+];
+
+export default sqlDataTypes;