From 0b91d9f4c37a50c57774f171c0a43736912ae072 Mon Sep 17 00:00:00 2001 From: 1ilit <1ilit@proton.me> Date: Thu, 9 Oct 2025 22:26:23 +0400 Subject: [PATCH] Fix import and export failing on non string column defaults for oracle (#637) --- src/data/schemas.js | 10 +++++----- src/utils/issues.js | 13 +++++++++++-- src/utils/utils.js | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/data/schemas.js b/src/data/schemas.js index 2b4e0e2..2c28a4b 100644 --- a/src/data/schemas.js +++ b/src/data/schemas.js @@ -13,7 +13,7 @@ export const tableSchema = { id: { type: ["integer", "string"] }, name: { type: "string" }, type: { type: "string" }, - default: { type: "string" }, + default: { type: ["string", "number", "boolean"] }, check: { type: "string" }, primary: { type: "boolean" }, unique: { type: "boolean" }, @@ -55,10 +55,10 @@ export const tableSchema = { }, }, color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" }, - }, - inherits: { - type: "array", - items: { type: ["string"] }, + inherits: { + type: "array", + items: { type: ["string"] }, + }, }, required: ["id", "name", "x", "y", "fields", "comment", "indices", "color"], }; diff --git a/src/utils/issues.js b/src/utils/issues.js index 0553bb4..4ab0fcb 100644 --- a/src/utils/issues.js +++ b/src/utils/issues.js @@ -5,7 +5,12 @@ import { isFunction } from "./utils"; function checkDefault(field, database) { if (field.default === "") return true; if (isFunction(field.default)) return true; - if (!field.notNull && field.default.toLowerCase() === "null") return true; + if ( + !field.notNull && + typeof field === "string" && + field.default.toLowerCase() === "null" + ) + return true; if (!dbToTypes[database][field.type].checkDefault) return true; return dbToTypes[database][field.type].checkDefault(field); @@ -67,7 +72,11 @@ export function getIssues(diagram) { ); } - if (field.notNull && field.default.toLowerCase() === "null") { + if ( + field.notNull && + typeof field.default === "string" && + field.default.toLowerCase() === "null" + ) { issues.push( i18n.t("not_null_is_null", { tableName: table.name, diff --git a/src/utils/utils.js b/src/utils/utils.js index afc3b75..a9a1ddb 100644 --- a/src/utils/utils.js +++ b/src/utils/utils.js @@ -41,10 +41,12 @@ const keywords = [ "CURRENT_TIME", "CURRENT_TIMESTAMP", "LOCALTIME", - "LOCALTIMESTAMP" + "LOCALTIMESTAMP", ]; export function isKeyword(str) { + if (typeof str !== "string") return false; + return keywords.includes(str.toUpperCase()); }