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

This commit is contained in:
1ilit
2025-10-09 22:26:23 +04:00
committed by GitHub
parent 005f89757e
commit 0b91d9f4c3
3 changed files with 19 additions and 8 deletions

View File

@@ -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"],
};

View File

@@ -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,

View File

@@ -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());
}