Skip to content

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

Fix import and export failing on non string column defaults for oracle (#637)

1ilit0b91d9f4c37a
diff --git a/src/data/schemas.js b/src/data/schemas.js
index 2b4e0e22..2c28a4b4 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 0553bb49..4ab0fcb4 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 afc3b75d..a9a1ddbb 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());
}