Support unsigned types (#177)
This commit is contained in:
parent
1df8e4d4e0
commit
2f1cca13d6
@ -299,6 +299,44 @@ export default function FieldDetails({ data, tid, index }) {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{databases[database].hasUnsignedTypes &&
|
||||||
|
dbToTypes[database][data.type].signed && (
|
||||||
|
<div className="flex justify-between items-center my-3">
|
||||||
|
<div className="font-medium">{t("Unsigned")}</div>
|
||||||
|
<Checkbox
|
||||||
|
value="unsigned"
|
||||||
|
checked={data.unsigned}
|
||||||
|
onChange={(checkedValues) => {
|
||||||
|
setUndoStack((prev) => [
|
||||||
|
...prev,
|
||||||
|
{
|
||||||
|
action: Action.EDIT,
|
||||||
|
element: ObjectType.TABLE,
|
||||||
|
component: "field",
|
||||||
|
tid: tid,
|
||||||
|
fid: index,
|
||||||
|
undo: {
|
||||||
|
[checkedValues.target.value]:
|
||||||
|
!checkedValues.target.checked,
|
||||||
|
},
|
||||||
|
redo: {
|
||||||
|
[checkedValues.target.value]:
|
||||||
|
checkedValues.target.checked,
|
||||||
|
},
|
||||||
|
message: t("edit_table", {
|
||||||
|
tableName: tables[tid].name,
|
||||||
|
extra: "[field]",
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
setRedoStack([]);
|
||||||
|
updateField(tid, index, {
|
||||||
|
unsigned: checkedValues.target.checked,
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
<div className="font-semibold">{t("comment")}</div>
|
<div className="font-semibold">{t("comment")}</div>
|
||||||
<TextArea
|
<TextArea
|
||||||
className="my-2"
|
className="my-2"
|
||||||
|
@ -13,6 +13,7 @@ export const databases = new Proxy(
|
|||||||
label: DB.MYSQL,
|
label: DB.MYSQL,
|
||||||
image: mysqlImage,
|
image: mysqlImage,
|
||||||
hasTypes: false,
|
hasTypes: false,
|
||||||
|
hasUnsignedTypes: true,
|
||||||
},
|
},
|
||||||
[DB.POSTGRES]: {
|
[DB.POSTGRES]: {
|
||||||
name: "PostgreSQL",
|
name: "PostgreSQL",
|
||||||
@ -33,6 +34,7 @@ export const databases = new Proxy(
|
|||||||
label: DB.MARIADB,
|
label: DB.MARIADB,
|
||||||
image: mariadbImage,
|
image: mariadbImage,
|
||||||
hasTypes: false,
|
hasTypes: false,
|
||||||
|
hasUnsignedTypes: true,
|
||||||
},
|
},
|
||||||
[DB.MSSQL]: {
|
[DB.MSSQL]: {
|
||||||
name: "MSSQL",
|
name: "MSSQL",
|
||||||
|
@ -279,6 +279,7 @@ const mysqlTypesBase = {
|
|||||||
isSized: false,
|
isSized: false,
|
||||||
hasPrecision: false,
|
hasPrecision: false,
|
||||||
canIncrement: true,
|
canIncrement: true,
|
||||||
|
signed: true,
|
||||||
},
|
},
|
||||||
SMALLINT: {
|
SMALLINT: {
|
||||||
type: "SMALLINT",
|
type: "SMALLINT",
|
||||||
@ -289,6 +290,7 @@ const mysqlTypesBase = {
|
|||||||
isSized: false,
|
isSized: false,
|
||||||
hasPrecision: false,
|
hasPrecision: false,
|
||||||
canIncrement: true,
|
canIncrement: true,
|
||||||
|
signed: true,
|
||||||
},
|
},
|
||||||
MEDIUMINT: {
|
MEDIUMINT: {
|
||||||
type: "MEDIUMINT",
|
type: "MEDIUMINT",
|
||||||
@ -299,6 +301,7 @@ const mysqlTypesBase = {
|
|||||||
isSized: false,
|
isSized: false,
|
||||||
hasPrecision: false,
|
hasPrecision: false,
|
||||||
canIncrement: true,
|
canIncrement: true,
|
||||||
|
signed: true,
|
||||||
},
|
},
|
||||||
INTEGER: {
|
INTEGER: {
|
||||||
type: "INTEGER",
|
type: "INTEGER",
|
||||||
@ -309,6 +312,7 @@ const mysqlTypesBase = {
|
|||||||
isSized: false,
|
isSized: false,
|
||||||
hasPrecision: false,
|
hasPrecision: false,
|
||||||
canIncrement: true,
|
canIncrement: true,
|
||||||
|
signed: true,
|
||||||
},
|
},
|
||||||
BIGINT: {
|
BIGINT: {
|
||||||
type: "BIGINT",
|
type: "BIGINT",
|
||||||
@ -319,6 +323,7 @@ const mysqlTypesBase = {
|
|||||||
isSized: false,
|
isSized: false,
|
||||||
hasPrecision: false,
|
hasPrecision: false,
|
||||||
canIncrement: true,
|
canIncrement: true,
|
||||||
|
signed: true,
|
||||||
},
|
},
|
||||||
DECIMAL: {
|
DECIMAL: {
|
||||||
type: "DECIMAL",
|
type: "DECIMAL",
|
||||||
|
@ -235,6 +235,7 @@ const en = {
|
|||||||
declare_array: "Declare array",
|
declare_array: "Declare array",
|
||||||
empty_index_name: "Declared an index with no name in table '{{tableName}}'",
|
empty_index_name: "Declared an index with no name in table '{{tableName}}'",
|
||||||
didnt_find_diagram: "Oops! Didn't find the diagram.",
|
didnt_find_diagram: "Oops! Didn't find the diagram.",
|
||||||
|
unsigned: "Unsigned",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ export function toMariaDB(diagram) {
|
|||||||
(field) =>
|
(field) =>
|
||||||
`${exportFieldComment(field.comment)}\t\`${
|
`${exportFieldComment(field.comment)}\t\`${
|
||||||
field.name
|
field.name
|
||||||
}\` ${field.type}${field.notNull ? " NOT NULL" : ""}${
|
}\` ${field.type}${field.unsigned ? " UNSIGNED" : ""}${field.notNull ? " NOT NULL" : ""}${
|
||||||
field.increment ? " AUTO_INCREMENT" : ""
|
field.increment ? " AUTO_INCREMENT" : ""
|
||||||
}${field.unique ? " UNIQUE" : ""}${
|
}${field.unique ? " UNIQUE" : ""}${
|
||||||
field.default !== ""
|
field.default !== ""
|
||||||
|
@ -13,7 +13,7 @@ export function toMySQL(diagram) {
|
|||||||
(field) =>
|
(field) =>
|
||||||
`${exportFieldComment(field.comment)}\t\`${
|
`${exportFieldComment(field.comment)}\t\`${
|
||||||
field.name
|
field.name
|
||||||
}\` ${field.type}${field.size !== undefined && field.size !== "" ? "(" + field.size + ")" : ""}${
|
}\` ${field.type}${field.unsigned ? " UNSIGNED" : ""}${field.size !== undefined && field.size !== "" ? "(" + field.size + ")" : ""}${
|
||||||
field.notNull ? " NOT NULL" : ""
|
field.notNull ? " NOT NULL" : ""
|
||||||
}${
|
}${
|
||||||
field.increment ? " AUTO_INCREMENT" : ""
|
field.increment ? " AUTO_INCREMENT" : ""
|
||||||
|
Loading…
Reference in New Issue
Block a user