Fix error when field.values is undefined and add it to issues
This commit is contained in:
parent
aa7b8905b8
commit
81792a5243
@ -377,11 +377,26 @@ export default function Table(props) {
|
||||
(value === "INT" ||
|
||||
value === "BIGINT" ||
|
||||
value === "SMALLINT");
|
||||
updateField(props.tableData.id, j, {
|
||||
type: value,
|
||||
length: value === "VARCHAR" ? 255 : "",
|
||||
increment: incr,
|
||||
});
|
||||
if (value === "ENUM" || value === "SET") {
|
||||
updateField(props.tableData.id, j, {
|
||||
type: value,
|
||||
values: [],
|
||||
increment: incr,
|
||||
});
|
||||
} else if (value === "VARCHAR") {
|
||||
updateField(props.tableData.id, j, {
|
||||
type: value,
|
||||
length: 255,
|
||||
increment: incr,
|
||||
});
|
||||
} else {
|
||||
updateField(props.tableData.id, j, {
|
||||
type: value,
|
||||
increment: incr,
|
||||
length: "",
|
||||
values: [],
|
||||
});
|
||||
}
|
||||
}}
|
||||
></Select>
|
||||
</Col>
|
||||
@ -1102,7 +1117,6 @@ export default function Table(props) {
|
||||
type: "",
|
||||
default: "",
|
||||
check: "",
|
||||
length: "",
|
||||
primary: false,
|
||||
unique: false,
|
||||
notNull: false,
|
||||
|
@ -223,11 +223,26 @@ export default function TableOverview(props) {
|
||||
(value === "INT" ||
|
||||
value === "BIGINT" ||
|
||||
value === "SMALLINT");
|
||||
updateField(i, j, {
|
||||
type: value,
|
||||
length: value === "VARCHAR" ? 255 : "",
|
||||
increment: incr,
|
||||
});
|
||||
if (value === "ENUM" || value === "SET") {
|
||||
updateField(i, j, {
|
||||
type: value,
|
||||
values: [],
|
||||
increment: incr,
|
||||
});
|
||||
} else if (value === "VARCHAR") {
|
||||
updateField(i, j, {
|
||||
type: value,
|
||||
length: 255,
|
||||
increment: incr,
|
||||
});
|
||||
} else {
|
||||
updateField(i, j, {
|
||||
type: value,
|
||||
increment: incr,
|
||||
length: "",
|
||||
values: [],
|
||||
});
|
||||
}
|
||||
}}
|
||||
></Select>
|
||||
</Col>
|
||||
@ -975,7 +990,6 @@ export default function TableOverview(props) {
|
||||
default: "",
|
||||
check: "",
|
||||
primary: false,
|
||||
length: "",
|
||||
unique: false,
|
||||
notNull: false,
|
||||
increment: false,
|
||||
|
@ -95,7 +95,6 @@ export default function Editor(props) {
|
||||
unique: true,
|
||||
notNull: true,
|
||||
increment: true,
|
||||
length: "",
|
||||
comment: "",
|
||||
id: 0,
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ function jsonToSQL(obj) {
|
||||
`${field.comment === "" ? "" : `\t-- ${field.comment}\n`}\t\`${
|
||||
field.name
|
||||
}\` ${field.type}${
|
||||
field.length !== ""
|
||||
field.type === "VARCHAR"
|
||||
? `(${field.length})`
|
||||
: field.type === "ENUM" || field.type === "SET"
|
||||
? `(${field.values.map((v) => `"${v}"`).join(", ")})`
|
||||
@ -142,6 +142,12 @@ function validateDiagram(diagram) {
|
||||
}
|
||||
if (field.type === "") {
|
||||
issues.push(`Empty field type in table "${table.name}"`);
|
||||
} else if (field.type === "ENUM" || field.type === "SET") {
|
||||
if (!field.values || field.values.length === 0) {
|
||||
issues.push(
|
||||
`"${field.name}" field of table "${table.name}" is of type ${field.type} but values have been specified`
|
||||
);
|
||||
}
|
||||
}
|
||||
if (duplicateFieldNames[field.name]) {
|
||||
issues.push(`Duplicate table fields in table "${table.name}"`);
|
||||
|
Loading…
Reference in New Issue
Block a user