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 === "INT" ||
|
||||||
value === "BIGINT" ||
|
value === "BIGINT" ||
|
||||||
value === "SMALLINT");
|
value === "SMALLINT");
|
||||||
updateField(props.tableData.id, j, {
|
if (value === "ENUM" || value === "SET") {
|
||||||
type: value,
|
updateField(props.tableData.id, j, {
|
||||||
length: value === "VARCHAR" ? 255 : "",
|
type: value,
|
||||||
increment: incr,
|
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>
|
></Select>
|
||||||
</Col>
|
</Col>
|
||||||
@ -1102,7 +1117,6 @@ export default function Table(props) {
|
|||||||
type: "",
|
type: "",
|
||||||
default: "",
|
default: "",
|
||||||
check: "",
|
check: "",
|
||||||
length: "",
|
|
||||||
primary: false,
|
primary: false,
|
||||||
unique: false,
|
unique: false,
|
||||||
notNull: false,
|
notNull: false,
|
||||||
|
@ -223,11 +223,26 @@ export default function TableOverview(props) {
|
|||||||
(value === "INT" ||
|
(value === "INT" ||
|
||||||
value === "BIGINT" ||
|
value === "BIGINT" ||
|
||||||
value === "SMALLINT");
|
value === "SMALLINT");
|
||||||
updateField(i, j, {
|
if (value === "ENUM" || value === "SET") {
|
||||||
type: value,
|
updateField(i, j, {
|
||||||
length: value === "VARCHAR" ? 255 : "",
|
type: value,
|
||||||
increment: incr,
|
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>
|
></Select>
|
||||||
</Col>
|
</Col>
|
||||||
@ -975,7 +990,6 @@ export default function TableOverview(props) {
|
|||||||
default: "",
|
default: "",
|
||||||
check: "",
|
check: "",
|
||||||
primary: false,
|
primary: false,
|
||||||
length: "",
|
|
||||||
unique: false,
|
unique: false,
|
||||||
notNull: false,
|
notNull: false,
|
||||||
increment: false,
|
increment: false,
|
||||||
|
@ -95,7 +95,6 @@ export default function Editor(props) {
|
|||||||
unique: true,
|
unique: true,
|
||||||
notNull: true,
|
notNull: true,
|
||||||
increment: true,
|
increment: true,
|
||||||
length: "",
|
|
||||||
comment: "",
|
comment: "",
|
||||||
id: 0,
|
id: 0,
|
||||||
},
|
},
|
||||||
|
@ -59,7 +59,7 @@ function jsonToSQL(obj) {
|
|||||||
`${field.comment === "" ? "" : `\t-- ${field.comment}\n`}\t\`${
|
`${field.comment === "" ? "" : `\t-- ${field.comment}\n`}\t\`${
|
||||||
field.name
|
field.name
|
||||||
}\` ${field.type}${
|
}\` ${field.type}${
|
||||||
field.length !== ""
|
field.type === "VARCHAR"
|
||||||
? `(${field.length})`
|
? `(${field.length})`
|
||||||
: field.type === "ENUM" || field.type === "SET"
|
: field.type === "ENUM" || field.type === "SET"
|
||||||
? `(${field.values.map((v) => `"${v}"`).join(", ")})`
|
? `(${field.values.map((v) => `"${v}"`).join(", ")})`
|
||||||
@ -142,6 +142,12 @@ function validateDiagram(diagram) {
|
|||||||
}
|
}
|
||||||
if (field.type === "") {
|
if (field.type === "") {
|
||||||
issues.push(`Empty field type in table "${table.name}"`);
|
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]) {
|
if (duplicateFieldNames[field.name]) {
|
||||||
issues.push(`Duplicate table fields in table "${table.name}"`);
|
issues.push(`Duplicate table fields in table "${table.name}"`);
|
||||||
|
Loading…
Reference in New Issue
Block a user