From 3cb37beed1c1a9c330e8909797cba5243d9c4f07 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?ZR21080178-=E9=97=AB=E5=BF=97=E6=B5=A9?= <273697776@qq.com>
Date: Sat, 4 May 2024 14:42:11 +0800
Subject: [PATCH 1/4] fix issues.js checkDefault bug
---
src/utils/issues.js | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/src/utils/issues.js b/src/utils/issues.js
index 90e12599..421e9ae8 100644
--- a/src/utils/issues.js
+++ b/src/utils/issues.js
@@ -11,6 +11,8 @@ function checkDefault(field) {
if (isFunction(field.default)) return true;
+ if (Array.isArray(field.default.name)) return true;
+
if (!field.notNull && field.default.toLowerCase() === "null") return true;
switch (field.type) {
@@ -124,7 +126,7 @@ export function getIssues(diagram) {
);
}
- if (field.notNull && field.default.toLowerCase() === "null") {
+ if (field.notNull && !Array.isArray(field.default.name) && field.default.toLowerCase() === "null") {
issues.push(
`"${field.name}" field of table "${table.name}" is NOT NULL but has default NULL`,
);
From e4940f907f18e02854e895cc3ac5c37dc7d61b9e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?ZR21080178-=E9=97=AB=E5=BF=97=E6=B5=A9?= <273697776@qq.com>
Date: Sat, 4 May 2024 16:10:06 +0800
Subject: [PATCH 2/4] fix table default value bug
---
src/components/EditorCanvas/Table.jsx | 7 ++++++-
src/utils/astToDiagram.js | 1 +
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/src/components/EditorCanvas/Table.jsx b/src/components/EditorCanvas/Table.jsx
index 12b67271..c93416d4 100644
--- a/src/components/EditorCanvas/Table.jsx
+++ b/src/components/EditorCanvas/Table.jsx
@@ -184,6 +184,11 @@ export default function Table(props) {
{tableData.fields.map((e, i) => {
+
+ if (e.default.name && e.default.name[0].value && e.default.name[0].value === 'CURRENT_TIMESTAMP') {
+ e.default = 'CURRENT_TIMESTAMP'
+ }
+
return settings.showFieldSummary ? (
Comment: diff --git a/src/utils/astToDiagram.js b/src/utils/astToDiagram.js index 92991ad6..de3f3dd8 100644 --- a/src/utils/astToDiagram.js +++ b/src/utils/astToDiagram.js @@ -46,6 +46,7 @@ export function astToDiagram(ast) { const relationships = []; ast.forEach((e) => { + console.log(e) if (e.type === "create") { if (e.keyword === "table") { const table = {}; From 942c0185128e863036f7a490cb29d6c09d9f93ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZR21080178-=E9=97=AB=E5=BF=97=E6=B5=A9?= <273697776@qq.com> Date: Sat, 4 May 2024 16:10:43 +0800 Subject: [PATCH 3/4] Update Table.jsx --- src/components/EditorCanvas/Table.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/EditorCanvas/Table.jsx b/src/components/EditorCanvas/Table.jsx index c93416d4..98b5b3a0 100644 --- a/src/components/EditorCanvas/Table.jsx +++ b/src/components/EditorCanvas/Table.jsx @@ -221,7 +221,7 @@ export default function Table(props) { )}
Default: - {e.default === "" ? "Not set" : e.default + ''} + {e.default === "" ? "Not set" : e.default}
Comment: From 22bfa7cb6bee56cd9601eb92507a480a8938b047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ZR21080178-=E9=97=AB=E5=BF=97=E6=B5=A9?= <273697776@qq.com> Date: Sat, 4 May 2024 16:16:22 +0800 Subject: [PATCH 4/4] Update astToDiagram.js delete log --- src/utils/astToDiagram.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/utils/astToDiagram.js b/src/utils/astToDiagram.js index de3f3dd8..92991ad6 100644 --- a/src/utils/astToDiagram.js +++ b/src/utils/astToDiagram.js @@ -46,7 +46,6 @@ export function astToDiagram(ast) { const relationships = []; ast.forEach((e) => { - console.log(e) if (e.type === "create") { if (e.keyword === "table") { const table = {};