add sets
This commit is contained in:
parent
662e2294e8
commit
2760f458af
@ -348,17 +348,11 @@ export default function Table(props) {
|
||||
(value === "INT" ||
|
||||
value === "BIGINT" ||
|
||||
value === "SMALLINT");
|
||||
updateField(
|
||||
props.tableData.id,
|
||||
j,
|
||||
value === "ENUM"
|
||||
? { type: value, enumValues: [], increment: incr }
|
||||
: {
|
||||
updateField(props.tableData.id, j, {
|
||||
type: value,
|
||||
length: value === "VARCHAR" ? 255 : "n/a",
|
||||
increment: incr,
|
||||
}
|
||||
);
|
||||
});
|
||||
}}
|
||||
></Select>
|
||||
</Col>
|
||||
@ -450,26 +444,26 @@ export default function Table(props) {
|
||||
setRedoStack([]);
|
||||
}}
|
||||
/>
|
||||
{f.type === "ENUM" && (
|
||||
{(f.type === "ENUM" || f.type === "SET") && (
|
||||
<>
|
||||
<div className="font-semibold mb-1">Enum values</div>
|
||||
<div className="font-semibold mb-1">
|
||||
{f.type} values
|
||||
</div>
|
||||
<TagInput
|
||||
separator={[",", ", ", " ,"]}
|
||||
value={f.enumValues}
|
||||
value={f.values}
|
||||
className="my-2"
|
||||
placeholder="Use ',' for batch input"
|
||||
onChange={(v) =>
|
||||
updateField(props.tableData.id, j, {
|
||||
enumValues: v,
|
||||
values: v,
|
||||
})
|
||||
}
|
||||
onFocus={(e) =>
|
||||
setEditField({ enumValues: f.enumValues })
|
||||
}
|
||||
onFocus={(e) => setEditField({ values: f.values })}
|
||||
onBlur={(e) => {
|
||||
if (
|
||||
JSON.stringify(editField.enumValues) ===
|
||||
JSON.stringify(f.enumValues)
|
||||
JSON.stringify(editField.values) ===
|
||||
JSON.stringify(f.values)
|
||||
)
|
||||
return;
|
||||
setUndoStack((prev) => [
|
||||
@ -481,7 +475,7 @@ export default function Table(props) {
|
||||
tid: props.tableData.id,
|
||||
fid: j,
|
||||
undo: editField,
|
||||
redo: { enumValues: f.enumValues },
|
||||
redo: { values: f.values },
|
||||
},
|
||||
]);
|
||||
setRedoStack([]);
|
||||
|
@ -183,17 +183,11 @@ export default function TableOverview(props) {
|
||||
(value === "INT" ||
|
||||
value === "BIGINT" ||
|
||||
value === "SMALLINT");
|
||||
updateField(
|
||||
i,
|
||||
j,
|
||||
value === "ENUM"
|
||||
? { type: value, enumValues: [], increment: incr }
|
||||
: {
|
||||
updateField(i, j, {
|
||||
type: value,
|
||||
length: value === "VARCHAR" ? 255 : "n/a",
|
||||
increment: incr,
|
||||
}
|
||||
);
|
||||
});
|
||||
}}
|
||||
></Select>
|
||||
</Col>
|
||||
@ -286,26 +280,26 @@ export default function TableOverview(props) {
|
||||
setRedoStack([]);
|
||||
}}
|
||||
/>
|
||||
{f.type === "ENUM" && (
|
||||
{(f.type === "ENUM" || f.type === "SET") && (
|
||||
<>
|
||||
<div className="font-semibold mb-1">
|
||||
Enum values
|
||||
{f.type} values
|
||||
</div>
|
||||
<TagInput
|
||||
separator={[",", ", ", " ,"]}
|
||||
value={f.enumValues}
|
||||
value={f.values}
|
||||
className="my-2"
|
||||
placeholder="Use ',' for batch input"
|
||||
onChange={(v) =>
|
||||
updateField(i, j, { enumValues: v })
|
||||
updateField(i, j, { values: v })
|
||||
}
|
||||
onFocus={(e) =>
|
||||
setEditField({ enumValues: f.enumValues })
|
||||
setEditField({ values: f.values })
|
||||
}
|
||||
onBlur={(e) => {
|
||||
if (
|
||||
JSON.stringify(editField.enumValues) ===
|
||||
JSON.stringify(f.enumValues)
|
||||
JSON.stringify(editField.values) ===
|
||||
JSON.stringify(f.values)
|
||||
)
|
||||
return;
|
||||
setUndoStack((prev) => [
|
||||
@ -317,7 +311,7 @@ export default function TableOverview(props) {
|
||||
tid: i,
|
||||
fid: j,
|
||||
undo: editField,
|
||||
redo: { enumValues: f.enumValues },
|
||||
redo: { values: f.values },
|
||||
},
|
||||
]);
|
||||
setRedoStack([]);
|
||||
|
@ -20,6 +20,7 @@ const sqlDataTypes = [
|
||||
"BLOB",
|
||||
"JSON",
|
||||
"ENUM",
|
||||
"SET",
|
||||
];
|
||||
|
||||
const tableThemes = [
|
||||
|
@ -19,6 +19,8 @@ const tableSchema = {
|
||||
notNull: { type: "boolean" },
|
||||
increment: { type: "boolean" },
|
||||
comment: { type: "string" },
|
||||
length: { type: ["string", "number"] },
|
||||
values: { type: "array", items: { type: "string" } },
|
||||
},
|
||||
required: [
|
||||
"name",
|
||||
@ -30,6 +32,7 @@ const tableSchema = {
|
||||
"notNull",
|
||||
"increment",
|
||||
"comment",
|
||||
"length",
|
||||
],
|
||||
},
|
||||
},
|
||||
@ -86,69 +89,7 @@ const jsonSchema = {
|
||||
properties: {
|
||||
tables: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "integer" },
|
||||
name: { type: "string" },
|
||||
x: { type: "number" },
|
||||
y: { type: "number" },
|
||||
fields: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: { type: "string" },
|
||||
type: { type: "string" },
|
||||
default: { type: "string" },
|
||||
check: { type: "string" },
|
||||
primary: { type: "boolean" },
|
||||
unique: { type: "boolean" },
|
||||
notNull: { type: "boolean" },
|
||||
increment: { type: "boolean" },
|
||||
comment: { type: "string" },
|
||||
},
|
||||
required: [
|
||||
"name",
|
||||
"type",
|
||||
"default",
|
||||
"check",
|
||||
"primary",
|
||||
"unique",
|
||||
"notNull",
|
||||
"increment",
|
||||
"comment",
|
||||
],
|
||||
},
|
||||
},
|
||||
comment: { type: "string" },
|
||||
indices: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: { type: "string" },
|
||||
fields: {
|
||||
type: "array",
|
||||
items: { type: "string" },
|
||||
},
|
||||
},
|
||||
required: ["name", "fields"],
|
||||
},
|
||||
},
|
||||
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
||||
},
|
||||
required: [
|
||||
"id",
|
||||
"name",
|
||||
"x",
|
||||
"y",
|
||||
"fields",
|
||||
"comment",
|
||||
"indices",
|
||||
"color",
|
||||
],
|
||||
},
|
||||
items: { ...tableSchema },
|
||||
},
|
||||
relationships: {
|
||||
type: "array",
|
||||
@ -190,35 +131,11 @@ const jsonSchema = {
|
||||
},
|
||||
notes: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "integer" },
|
||||
x: { type: "number" },
|
||||
y: { type: "number" },
|
||||
title: { type: "string" },
|
||||
content: { type: "string" },
|
||||
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
||||
height: { type: "number" },
|
||||
},
|
||||
required: ["id", "x", "y", "title", "content", "color", "height"],
|
||||
},
|
||||
items: { ...noteSchema },
|
||||
},
|
||||
subjectAreas: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "integer" },
|
||||
name: { type: "string" },
|
||||
x: { type: "number" },
|
||||
y: { type: "number" },
|
||||
width: { type: "number" },
|
||||
height: { type: "number" },
|
||||
color: { type: "string", pattern: "^#[0-9a-fA-F]{6}$" },
|
||||
},
|
||||
required: ["id", "name", "x", "y", "width", "height", "color"],
|
||||
},
|
||||
items: { ...areaSchema },
|
||||
},
|
||||
},
|
||||
required: ["tables", "relationships", "notes", "subjectAreas"],
|
||||
|
@ -61,8 +61,8 @@ function jsonToSQL(obj) {
|
||||
}\` ${field.type}${
|
||||
field.length !== "n/a"
|
||||
? `(${field.length})`
|
||||
: field.enumValues
|
||||
? `(${field.enumValues.map((v) => `"${v}"`).join(", ")})`
|
||||
: field.type === "ENUM" || field.type === "SET"
|
||||
? `(${field.values.map((v) => `"${v}"`).join(", ")})`
|
||||
: ""
|
||||
}${field.notNull ? " NOT NULL" : ""}${
|
||||
field.increment ? " AUTO_INCREMENT" : ""
|
||||
|
Loading…
Reference in New Issue
Block a user