diff --git a/backend/packages/Upgrade/src/api/controllers/StratificationController.ts b/backend/packages/Upgrade/src/api/controllers/StratificationController.ts index d98ed58319..217d067d8e 100644 --- a/backend/packages/Upgrade/src/api/controllers/StratificationController.ts +++ b/backend/packages/Upgrade/src/api/controllers/StratificationController.ts @@ -304,7 +304,7 @@ export class StratificationController { @UseBefore(upload.single('file')) public insertStratification(@Req() request: AppRequest): Promise { const csvData = request.body[0].file; - const rows = csvData.split('\n'); + const rows = csvData.replace(/"/g, '').split('\n'); const columnNames = rows[0].split(','); const userFactorValues: StratificationInputValidator[] = []; diff --git a/backend/packages/Upgrade/src/api/models/Experiment.ts b/backend/packages/Upgrade/src/api/models/Experiment.ts index d5b03ccbe1..80d18e0f16 100644 --- a/backend/packages/Upgrade/src/api/models/Experiment.ts +++ b/backend/packages/Upgrade/src/api/models/Experiment.ts @@ -130,6 +130,7 @@ export class Experiment extends BaseModel { @ManyToOne(() => StratificationFactor, (stratificationFactor) => stratificationFactor.experiment, { onDelete: 'CASCADE', + nullable: true, }) public stratificationFactor: StratificationFactor; diff --git a/backend/packages/Upgrade/src/api/services/ExperimentService.ts b/backend/packages/Upgrade/src/api/services/ExperimentService.ts index c780ddd9cf..19ab0138db 100644 --- a/backend/packages/Upgrade/src/api/services/ExperimentService.ts +++ b/backend/packages/Upgrade/src/api/services/ExperimentService.ts @@ -709,7 +709,7 @@ export class ExperimentService { } = experiment; // create stratificationFactor is not found - if (!expDoc.stratificationFactor.id) { + if (expDoc.stratificationFactor.id) { expDoc.stratificationFactor.id = uuid(); await transactionalEntityManager.getRepository(StratificationFactor).save(expDoc.stratificationFactor); } @@ -1141,7 +1141,7 @@ export class ExperimentService { this.checkConditionCodeDefault(conditions); // create stratificationFactor is not found - if (!expDoc.stratificationFactor.id) { + if (expDoc.stratificationFactor.id) { expDoc.stratificationFactor.id = uuid(); await transactionalEntityManager.getRepository(StratificationFactor).save(expDoc.stratificationFactor); }