Making sure all protected columns are kept during row save/patch operations.
This commit is contained in:
parent
b8c10d4765
commit
6edaf5e160
|
@ -31,6 +31,8 @@ import {
|
||||||
import { isExternalTableID } from "../../integrations/utils"
|
import { isExternalTableID } from "../../integrations/utils"
|
||||||
import {
|
import {
|
||||||
helpers,
|
helpers,
|
||||||
|
isExternalColumnName,
|
||||||
|
isInternalColumnName,
|
||||||
PROTECTED_EXTERNAL_COLUMNS,
|
PROTECTED_EXTERNAL_COLUMNS,
|
||||||
PROTECTED_INTERNAL_COLUMNS,
|
PROTECTED_INTERNAL_COLUMNS,
|
||||||
} from "@budibase/shared-core"
|
} from "@budibase/shared-core"
|
||||||
|
@ -202,14 +204,18 @@ export async function inputProcessing(
|
||||||
const clonedRow = cloneDeep(row)
|
const clonedRow = cloneDeep(row)
|
||||||
const table = await getTableFromSource(source)
|
const table = await getTableFromSource(source)
|
||||||
|
|
||||||
const dontCleanseKeys = ["type", "_id", "_rev", "tableId"]
|
|
||||||
for (const [key, value] of Object.entries(clonedRow)) {
|
for (const [key, value] of Object.entries(clonedRow)) {
|
||||||
const field = table.schema[key]
|
const field = table.schema[key]
|
||||||
// cleanse fields that aren't in the schema
|
// cleanse fields that aren't in the schema
|
||||||
|
if (
|
||||||
|
!field && isExternalTableID(table._id!)
|
||||||
|
? !isExternalColumnName(key)
|
||||||
|
: !isInternalColumnName(key)
|
||||||
|
) {
|
||||||
|
delete clonedRow[key]
|
||||||
|
}
|
||||||
|
// field isn't found - might be a built-in column, skip over it
|
||||||
if (!field) {
|
if (!field) {
|
||||||
if (dontCleanseKeys.indexOf(key) === -1) {
|
|
||||||
delete clonedRow[key]
|
|
||||||
}
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// remove any formula values, they are to be generated
|
// remove any formula values, they are to be generated
|
||||||
|
|
|
@ -12,3 +12,7 @@ export const PROTECTED_EXTERNAL_COLUMNS = ["_id", "_rev", "tableId"] as const
|
||||||
export function isInternalColumnName(name: string): boolean {
|
export function isInternalColumnName(name: string): boolean {
|
||||||
return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name)
|
return (PROTECTED_INTERNAL_COLUMNS as readonly string[]).includes(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function isExternalColumnName(name: string): boolean {
|
||||||
|
return (PROTECTED_EXTERNAL_COLUMNS as readonly string[]).includes(name)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue