Skip to content

Commit 99d4bca

Browse files
authored
Merge branch 'main' into main
2 parents c21e51c + 2b85226 commit 99d4bca

File tree

5 files changed

+26
-11
lines changed

5 files changed

+26
-11
lines changed

src/components/EditorSidePanel/TypesTab/TypeField.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export default function TypeField({ data, tid, fid }) {
7878
})),
7979
...types
8080
.filter(
81-
(type) => type.name.toLowerCase() !== data.name.toLowerCase(),
81+
(type) => type.name.toLowerCase() !== types[tid].name.toLowerCase(),
8282
)
8383
.map((type) => ({
8484
label: type.name.toUpperCase(),

src/data/schemas.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export const tableSchema = {
1313
id: { type: ["integer", "string"] },
1414
name: { type: "string" },
1515
type: { type: "string" },
16-
default: { type: "string" },
16+
default: { type: ["string", "number", "boolean"] },
1717
check: { type: "string" },
1818
primary: { type: "boolean" },
1919
unique: { type: "boolean" },
@@ -55,10 +55,10 @@ export const tableSchema = {
5555
},
5656
},
5757
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
58-
},
59-
inherits: {
60-
type: "array",
61-
items: { type: ["string"] },
58+
inherits: {
59+
type: "array",
60+
items: { type: ["string"] },
61+
},
6262
},
6363
required: ["id", "name", "x", "y", "fields", "comment", "indices", "color"],
6464
};
@@ -148,7 +148,7 @@ export const jsonSchema = {
148148
cardinality: { type: "string" },
149149
updateConstraint: { type: "string" },
150150
deleteConstraint: { type: "string" },
151-
id: { type: "integer" },
151+
id: { type: ["integer", "string"] },
152152
},
153153
required: [
154154
"startTableId",

src/utils/exportAs/dbml.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@ function parseDefaultDbml(field, database) {
2929
}
3030

3131
function columnDefault(field, database) {
32-
if (!field.default || field.default.trim() === "") {
32+
if (!field.default) {
33+
return "";
34+
}
35+
36+
if (typeof field.default === "string" && !field.default.trim()) {
3337
return "";
3438
}
3539

src/utils/issues.js

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ import { isFunction } from "./utils";
55
function checkDefault(field, database) {
66
if (field.default === "") return true;
77
if (isFunction(field.default)) return true;
8-
if (!field.notNull && field.default.toLowerCase() === "null") return true;
8+
if (
9+
!field.notNull &&
10+
typeof field === "string" &&
11+
field.default.toLowerCase() === "null"
12+
)
13+
return true;
914
if (!dbToTypes[database][field.type].checkDefault) return true;
1015

1116
return dbToTypes[database][field.type].checkDefault(field);
@@ -67,7 +72,11 @@ export function getIssues(diagram) {
6772
);
6873
}
6974

70-
if (field.notNull && field.default.toLowerCase() === "null") {
75+
if (
76+
field.notNull &&
77+
typeof field.default === "string" &&
78+
field.default.toLowerCase() === "null"
79+
) {
7180
issues.push(
7281
i18n.t("not_null_is_null", {
7382
tableName: table.name,

src/utils/utils.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ const keywords = [
4141
"CURRENT_TIME",
4242
"CURRENT_TIMESTAMP",
4343
"LOCALTIME",
44-
"LOCALTIMESTAMP"
44+
"LOCALTIMESTAMP",
4545
];
4646

4747
export function isKeyword(str) {
48+
if (typeof str !== "string") return false;
49+
4850
return keywords.includes(str.toUpperCase());
4951
}
5052

0 commit comments

Comments
 (0)