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