Skip to content

Commit 1069200

Browse files
author
christopherholland-workday
committed
Fix Mass Assignment in Dataset and DatasetRow Operations
1 parent 7df6e95 commit 1069200

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

  • packages/server/src/services/dataset

packages/server/src/services/dataset/index.ts

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,9 @@ const createDataset = async (body: any) => {
200200
try {
201201
const appServer = getRunningExpressApp()
202202
const newDs = new Dataset()
203-
Object.assign(newDs, body)
203+
newDs.name = body.name
204+
newDs.description = body.description
205+
newDs.workspaceId = body.workspaceId
204206
const dataset = appServer.AppDataSource.getRepository(Dataset).create(newDs)
205207
const result = await appServer.AppDataSource.getRepository(Dataset).save(dataset)
206208
if (body.csvFile) {
@@ -222,9 +224,8 @@ const updateDataset = async (id: string, body: any, workspaceId: string) => {
222224
})
223225
if (!dataset) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset ${id} not found`)
224226

225-
const updateDataset = new Dataset()
226-
Object.assign(updateDataset, body)
227-
appServer.AppDataSource.getRepository(Dataset).merge(dataset, updateDataset)
227+
dataset.name = body.name
228+
dataset.description = body.description
228229
const result = await appServer.AppDataSource.getRepository(Dataset).save(dataset)
229230
return result
230231
} catch (error) {
@@ -271,7 +272,9 @@ const addDatasetRow = async (body: any) => {
271272
sequenceNo = maxValueEntity[0].sequenceNo
272273
}
273274
const newDs = new DatasetRow()
274-
Object.assign(newDs, body)
275+
newDs.input = body.input
276+
newDs.output = body.output
277+
newDs.datasetId = body.datasetId
275278
newDs.sequenceNo = sequenceNo === 0 ? sequenceNo : sequenceNo + 1
276279
const row = appServer.AppDataSource.getRepository(DatasetRow).create(newDs)
277280
const result = await appServer.AppDataSource.getRepository(DatasetRow).save(row)
@@ -311,11 +314,10 @@ const updateDatasetRow = async (id: string, body: any) => {
311314
})
312315
if (!item) throw new InternalFlowiseError(StatusCodes.NOT_FOUND, `Dataset Row ${id} not found`)
313316

314-
const updateItem = new DatasetRow()
315-
Object.assign(updateItem, body)
316-
appServer.AppDataSource.getRepository(DatasetRow).merge(item, updateItem)
317+
item.input = body.input
318+
item.output = body.output
317319
const result = await appServer.AppDataSource.getRepository(DatasetRow).save(item)
318-
await changeUpdateOnDataset(body.datasetId, body.workspaceId)
320+
await changeUpdateOnDataset(item.datasetId, body.workspaceId)
319321
return result
320322
} catch (error) {
321323
throw new InternalFlowiseError(

0 commit comments

Comments
 (0)