Fix checkDefault

This commit is contained in:
1ilit 2024-06-16 01:49:26 +03:00
parent 490cb738de
commit 4ba0e5af8b
2 changed files with 20 additions and 25 deletions

View File

@ -27,7 +27,7 @@ export default function FieldDetails({ data, tid, index }) {
className="my-2" className="my-2"
placeholder={t("default_value")} placeholder={t("default_value")}
value={data.default} value={data.default}
disabled={dbToTypes[database][data.type].hasDefault || data.increment} disabled={dbToTypes[database][data.type].noDefault || data.increment}
onChange={(value) => updateField(tid, index, { default: value })} onChange={(value) => updateField(tid, index, { default: value })}
onFocus={(e) => setEditField({ default: e.target.value })} onFocus={(e) => setEditField({ default: e.target.value })}
onBlur={(e) => { onBlur={(e) => {

View File

@ -111,7 +111,7 @@ export const defaultTypes = {
}, },
TEXT: { TEXT: {
type: "TEXT", type: "TEXT",
checkDefault: (field) => false, checkDefault: (field) => true,
hasCheck: false, hasCheck: false,
isSized: true, isSized: true,
hasPrecision: false, hasPrecision: false,
@ -214,7 +214,7 @@ export const defaultTypes = {
}, },
BLOB: { BLOB: {
type: "BLOB", type: "BLOB",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -222,7 +222,7 @@ export const defaultTypes = {
}, },
JSON: { JSON: {
type: "JSON", type: "JSON",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -230,7 +230,7 @@ export const defaultTypes = {
}, },
UUID: { UUID: {
type: "UUID", type: "UUID",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -491,7 +491,7 @@ export const mysqlTypes = {
}, },
TINYBLOB: { TINYBLOB: {
type: "TINYBLOB", type: "TINYBLOB",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -499,7 +499,7 @@ export const mysqlTypes = {
}, },
BLOB: { BLOB: {
type: "BLOB", type: "BLOB",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -507,7 +507,7 @@ export const mysqlTypes = {
}, },
MEDIUMBLOB: { MEDIUMBLOB: {
type: "MEDIUMBLOB", type: "MEDIUMBLOB",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -515,7 +515,7 @@ export const mysqlTypes = {
}, },
LONGBLOB: { LONGBLOB: {
type: "LONGBLOB", type: "LONGBLOB",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -603,7 +603,7 @@ export const mysqlTypes = {
}, },
GEOMETRY: { GEOMETRY: {
type: "GEOMETRY", type: "GEOMETRY",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -611,7 +611,7 @@ export const mysqlTypes = {
}, },
POINT: { POINT: {
type: "POINT", type: "POINT",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -619,7 +619,7 @@ export const mysqlTypes = {
}, },
LINESTRING: { LINESTRING: {
type: "LINESTRING", type: "LINESTRING",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -627,7 +627,7 @@ export const mysqlTypes = {
}, },
POLYGON: { POLYGON: {
type: "POLYGON", type: "POLYGON",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -635,7 +635,7 @@ export const mysqlTypes = {
}, },
MULTIPOINT: { MULTIPOINT: {
type: "MULTIPOINT", type: "MULTIPOINT",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -643,7 +643,7 @@ export const mysqlTypes = {
}, },
MULTILINESTRING: { MULTILINESTRING: {
type: "MULTILINESTRING", type: "MULTILINESTRING",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -651,7 +651,7 @@ export const mysqlTypes = {
}, },
MULTIPOLYGON: { MULTIPOLYGON: {
type: "MULTIPOLYGON", type: "MULTIPOLYGON",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -659,7 +659,7 @@ export const mysqlTypes = {
}, },
GEOMETRYCOLLECTION: { GEOMETRYCOLLECTION: {
type: "GEOMETRYCOLLECTION", type: "GEOMETRYCOLLECTION",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -667,7 +667,7 @@ export const mysqlTypes = {
}, },
JSON: { JSON: {
type: "JSON", type: "JSON",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,
@ -778,12 +778,7 @@ export const sqliteTypes = {
}, },
TEXT: { TEXT: {
type: "TEXT", type: "TEXT",
checkDefault: (field) => { checkDefault: (field) => true,
if (strHasQuotes(field.default)) {
return field.default.length - 2 <= field.size;
}
return field.default.length <= field.size;
},
hasCheck: true, hasCheck: true,
isSized: true, isSized: true,
hasPrecision: false, hasPrecision: false,
@ -792,7 +787,7 @@ export const sqliteTypes = {
}, },
BLOB: { BLOB: {
type: "BLOB", type: "BLOB",
checkDefault: (field) => false, checkDefault: (field) => true,
isSized: false, isSized: false,
hasCheck: false, hasCheck: false,
hasPrecision: false, hasPrecision: false,