Browse Source

fix: drop unused parameter

pull/6640/head
mertmit 1 year ago
parent
commit
c84699e65a
  1. 5
      packages/nc-gui/components/template/Editor.vue
  2. 2
      packages/nc-gui/composables/useColumnCreateStore.ts
  3. 19
      packages/nc-gui/utils/validation.ts

5
packages/nc-gui/components/template/Editor.vue

@ -128,10 +128,7 @@ const validators = computed(() =>
hasSelectColumn.value[tableIdx] = false hasSelectColumn.value[tableIdx] = false
table.columns?.forEach((column, columnIdx) => { table.columns?.forEach((column, columnIdx) => {
acc[`tables.${tableIdx}.columns.${columnIdx}.column_name`] = [ acc[`tables.${tableIdx}.columns.${columnIdx}.column_name`] = [fieldRequiredValidator(), fieldLengthValidator()]
fieldRequiredValidator(),
fieldLengthValidator(base.value?.sources?.[0].type || ClientType.MYSQL),
]
acc[`tables.${tableIdx}.columns.${columnIdx}.uidt`] = [fieldRequiredValidator()] acc[`tables.${tableIdx}.columns.${columnIdx}.uidt`] = [fieldRequiredValidator()]
if (isSelect(column)) { if (isSelect(column)) {
hasSelectColumn.value[tableIdx] = true hasSelectColumn.value[tableIdx] = true

2
packages/nc-gui/composables/useColumnCreateStore.ts

@ -126,7 +126,7 @@ const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState
}) })
}, },
}, },
fieldLengthValidator(baseType.value || ClientType.MYSQL), fieldLengthValidator(),
], ],
uidt: [ uidt: [
{ {

19
packages/nc-gui/utils/validation.ts

@ -98,25 +98,18 @@ export const fieldRequiredValidator = () => {
} }
} }
export const fieldLengthValidator = (_sqlClientType: string) => { export const fieldLengthValidator = () => {
return { return {
validator: (rule: any, value: any) => { validator: (rule: any, value: any) => {
const { t } = getI18n().global const { t } = getI18n().global
// mysql allows 64 characters for column_name
// postgres allows 59 characters for column_name
// mssql allows 128 characters for column_name
// sqlite allows any number of characters for column_name
// We allow 255 for all databases, truncate will be handled by backend for column_name
const fieldLengthLimit = 255 const fieldLengthLimit = 255
/*
Now we allow 255 for all databases, truncate will be handled by backend for column_name
if (sqlClientType === 'mysql2' || sqlClientType === 'mysql') {
fieldLengthLimit = 64
} else if (sqlClientType === 'pg') {
fieldLengthLimit = 59
} else if (sqlClientType === 'mssql') {
fieldLengthLimit = 128
}
*/
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
if (value?.length > fieldLengthLimit) { if (value?.length > fieldLengthLimit) {
reject(new Error(t('msg.error.columnNameExceedsCharacters', { value: fieldLengthLimit }))) reject(new Error(t('msg.error.columnNameExceedsCharacters', { value: fieldLengthLimit })))

Loading…
Cancel
Save