Fix
This commit is contained in:
parent
3f4484af00
commit
ad74eca709
|
@ -48,9 +48,7 @@ export async function save(
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for case sensitivity - we don't want to allow duplicated columns
|
// check for case sensitivity - we don't want to allow duplicated columns
|
||||||
const duplicateColumn = findDuplicateInternalColumns(table, {
|
const duplicateColumn = findDuplicateInternalColumns(table)
|
||||||
ignoreProtectedColumnNames: !oldTable && !!opts?.isImport,
|
|
||||||
})
|
|
||||||
if (duplicateColumn.length) {
|
if (duplicateColumn.length) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`Column(s) "${duplicateColumn.join(
|
`Column(s) "${duplicateColumn.join(
|
||||||
|
|
|
@ -53,10 +53,7 @@ export function canBeSortColumn(type: FieldType): boolean {
|
||||||
return !!allowSortColumnByType[type]
|
return !!allowSortColumnByType[type]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function findDuplicateInternalColumns(
|
export function findDuplicateInternalColumns(table: Table): string[] {
|
||||||
table: Table,
|
|
||||||
opts?: { ignoreProtectedColumnNames: boolean }
|
|
||||||
): string[] {
|
|
||||||
// maintains the case of keys
|
// maintains the case of keys
|
||||||
const casedKeys = Object.keys(table.schema)
|
const casedKeys = Object.keys(table.schema)
|
||||||
// get the column names
|
// get the column names
|
||||||
|
@ -72,11 +69,10 @@ export function findDuplicateInternalColumns(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!opts?.ignoreProtectedColumnNames) {
|
|
||||||
for (let internalColumn of PROTECTED_INTERNAL_COLUMNS) {
|
for (let internalColumn of PROTECTED_INTERNAL_COLUMNS) {
|
||||||
if (casedKeys.find(key => key === internalColumn)) {
|
if (casedKeys.find(key => key === internalColumn)) {
|
||||||
duplicates.push(internalColumn)
|
duplicates.push(internalColumn)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return duplicates
|
return duplicates
|
||||||
|
|
Loading…
Reference in New Issue