Don't change key order on trimming

This commit is contained in:
Adria Navarro 2024-08-14 13:13:15 +02:00
parent f53500450a
commit 09938ae442
1 changed files with 9 additions and 3 deletions

View File

@ -19,7 +19,6 @@ import {
User,
} from "@budibase/types"
import { cloneDeep } from "lodash/fp"
import { pick } from "lodash"
import {
processInputBBReference,
processInputBBReferences,
@ -368,9 +367,16 @@ export async function outputProcessing<T extends Row[] | Row>(
const tableFields = Object.keys(table.schema).filter(
f => table.schema[f].visible !== false
)
enriched = enriched.map((r: Row) =>
pick(r, [...tableFields, ...protectedColumns])
const fields = [...tableFields, ...protectedColumns].map(f =>
f.toLowerCase()
)
for (const row of enriched) {
for (const key of Object.keys(row)) {
if (!fields.includes(key.toLowerCase())) {
delete row[key]
}
}
}
}
return (wasArray ? enriched : enriched[0]) as T