Fix add field for types to work with dbToTypes

This commit is contained in:
1ilit 2024-06-27 11:34:21 +03:00
parent d79b0c205d
commit 259835892a
2 changed files with 26 additions and 6 deletions

View File

@ -268,7 +268,7 @@ export default function ControlPanel({
if (a.component === "field_add") { if (a.component === "field_add") {
updateType(a.tid, { updateType(a.tid, {
fields: types[a.tid].fields.filter( fields: types[a.tid].fields.filter(
(e, i) => i !== types[a.tid].fields.length - 1, (_, i) => i !== types[a.tid].fields.length - 1,
), ),
}); });
} }

View File

@ -5,7 +5,7 @@ const doubleRegex = /^-?\d*.?\d+$/;
const binaryRegex = /^[01]+$/; const binaryRegex = /^[01]+$/;
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
export const defaultTypes = { const defaultTypesBase = {
INT: { INT: {
type: "INT", type: "INT",
checkDefault: (field) => { checkDefault: (field) => {
@ -264,7 +264,11 @@ export const defaultTypes = {
}, },
}; };
export const mysqlTypes = { export const defaultTypes = new Proxy(defaultTypesBase, {
get: (target, prop) => (prop in target ? target[prop] : {}),
});
export const mysqlTypesBase = {
TINYINT: { TINYINT: {
type: "TINYINT", type: "TINYINT",
checkDefault: (field) => { checkDefault: (field) => {
@ -679,7 +683,11 @@ export const mysqlTypes = {
}, },
}; };
export const postgresTypes = { export const mysqlTypes = new Proxy(mysqlTypesBase, {
get: (target, prop) => (prop in target ? target[prop] : {}),
});
export const postgresTypesBase = {
SMALLINT: { SMALLINT: {
type: "SMALLINT", type: "SMALLINT",
checkDefault: (field) => { checkDefault: (field) => {
@ -1098,7 +1106,11 @@ export const postgresTypes = {
}, },
}; };
export const sqliteTypes = { export const postgresTypes = new Proxy(postgresTypesBase, {
get: (target, prop) => (prop in target ? target[prop] : {}),
});
export const sqliteTypesBase = {
INTEGER: { INTEGER: {
type: "INTEGER", type: "INTEGER",
checkDefault: (field) => { checkDefault: (field) => {
@ -1230,7 +1242,11 @@ export const sqliteTypes = {
}, },
}; };
export const mssqlTypes = { export const sqliteTypes = new Proxy(sqliteTypesBase, {
get: (target, prop) => (prop in target ? target[prop] : {}),
});
export const mssqlTypesBase = {
BIGINT: { type: "", checkDefault: (field) => {} }, BIGINT: { type: "", checkDefault: (field) => {} },
INTEGER: { type: "", checkDefault: (field) => {} }, INTEGER: { type: "", checkDefault: (field) => {} },
SMALLINT: { type: "", checkDefault: (field) => {} }, SMALLINT: { type: "", checkDefault: (field) => {} },
@ -1266,6 +1282,10 @@ export const mssqlTypes = {
JSON: { type: "", checkDefault: (field) => {} }, JSON: { type: "", checkDefault: (field) => {} },
}; };
export const mssqlTypes = new Proxy(mssqlTypesBase, {
get: (target, prop) => (prop in target ? target[prop] : {}),
});
const dbToTypesBase = { const dbToTypesBase = {
generic: defaultTypes, generic: defaultTypes,
mysql: mysqlTypes, mysql: mysqlTypes,