|
|
|
@ -18,7 +18,7 @@ const isAdvanceOptVisible = ref(false)
|
|
|
|
|
|
|
|
|
|
const { addTab } = useTabs() |
|
|
|
|
|
|
|
|
|
const { loadTables } = useProject() |
|
|
|
|
const { loadTables, isMysql, isMssql, isPg } = useProject() |
|
|
|
|
|
|
|
|
|
const { table, createTable, generateUniqueTitle, tables, project } = useTable(async (table) => { |
|
|
|
|
await loadTables() |
|
|
|
@ -40,7 +40,29 @@ const useForm = Form.useForm
|
|
|
|
|
|
|
|
|
|
const validators = computed(() => { |
|
|
|
|
return { |
|
|
|
|
title: [validateTableName, validateDuplicateAlias], |
|
|
|
|
title: [ |
|
|
|
|
validateTableName, |
|
|
|
|
validateDuplicateAlias, |
|
|
|
|
{ |
|
|
|
|
validator: (rule: any, value: any) => { |
|
|
|
|
return new Promise<void>((resolve, reject) => { |
|
|
|
|
let tableNameLengthLimit = 255 |
|
|
|
|
if (isMysql) { |
|
|
|
|
tableNameLengthLimit = 64 |
|
|
|
|
} else if (isPg) { |
|
|
|
|
tableNameLengthLimit = 63 |
|
|
|
|
} else if (isMssql) { |
|
|
|
|
tableNameLengthLimit = 128 |
|
|
|
|
} |
|
|
|
|
const projectPrefix = project?.value?.prefix || '' |
|
|
|
|
if ((projectPrefix + value).length > tableNameLengthLimit) { |
|
|
|
|
return reject(new Error(`Table name exceeds ${tableNameLengthLimit} characters`)) |
|
|
|
|
} |
|
|
|
|
resolve() |
|
|
|
|
}) |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
table_name: [validateTableName], |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|