|
|
@ -18,7 +18,7 @@ const isAdvanceOptVisible = ref(false) |
|
|
|
|
|
|
|
|
|
|
|
const { addTab } = useTabs() |
|
|
|
const { addTab } = useTabs() |
|
|
|
|
|
|
|
|
|
|
|
const { loadTables } = useProject() |
|
|
|
const { loadTables, isMysql, isMssql, isPg } = useProject() |
|
|
|
|
|
|
|
|
|
|
|
const { table, createTable, generateUniqueTitle, tables, project } = useTable(async (table) => { |
|
|
|
const { table, createTable, generateUniqueTitle, tables, project } = useTable(async (table) => { |
|
|
|
await loadTables() |
|
|
|
await loadTables() |
|
|
@ -40,7 +40,29 @@ const useForm = Form.useForm |
|
|
|
|
|
|
|
|
|
|
|
const validators = computed(() => { |
|
|
|
const validators = computed(() => { |
|
|
|
return { |
|
|
|
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], |
|
|
|
table_name: [validateTableName], |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|