Cloning table schema to avoid mutation.

This commit is contained in:
mike12345567 2023-08-14 11:19:00 +01:00
parent 672e370904
commit 97e5fe37a1
1 changed files with 2 additions and 2 deletions

View File

@ -1,11 +1,11 @@
import { import {
FieldSchema,
RenameColumn, RenameColumn,
TableSchema, TableSchema,
View, View,
ViewV2, ViewV2,
} from "@budibase/types" } from "@budibase/types"
import { context, HTTPError } from "@budibase/backend-core" import { context, HTTPError } from "@budibase/backend-core"
import { cloneDeep } from "lodash"
import sdk from "../../../sdk" import sdk from "../../../sdk"
import * as utils from "../../../db/utils" import * as utils from "../../../db/utils"
@ -78,7 +78,7 @@ export function enrichSchema(view: View | ViewV2, tableSchema: TableSchema) {
return view return view
} }
let schema = { ...tableSchema } let schema = cloneDeep(tableSchema)
const anyViewOrder = Object.values(view.schema || {}).some( const anyViewOrder = Object.values(view.schema || {}).some(
ui => ui.order != null ui => ui.order != null
) )