Skip to content

Commit 03e2c44

Browse files
authored
Issue 53804: Cross type import converts strings 'Yes' and 'No' to their boolean values (#7128)
1 parent e9d6c2f commit 03e2c44

File tree

4 files changed

+7
-21
lines changed

4 files changed

+7
-21
lines changed

api/src/org/labkey/api/query/AbstractQueryImportAction.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,7 @@ else if (!dataFileDir.exists())
628628
//di = wrap(di, ve);
629629
//importData(di, ve);
630630

631-
configureLoader(loader);
631+
configureLoader(loader, _target, getRenamedColumns(), allowLineageColumns(), getLineageImportAliases(), getOptionParamsMap());
632632

633633
TransactionAuditProvider.TransactionAuditEvent auditEvent = null;
634634
if (behaviorType != null && behaviorType != AuditBehaviorType.NONE)
@@ -669,13 +669,12 @@ else if (!dataFileDir.exists())
669669

670670
}
671671

672-
protected void configureLoader(DataLoader loader) throws IOException
672+
public static void configureLoader(DataLoader loader, @Nullable TableInfo target, @Nullable Map<String, String> renamedColumns, boolean allowLineageColumns, @Nullable Set<String> lineageAliasNames, @Nullable Map<Params, Boolean> optionParamsMap) throws IOException
673673
{
674-
configureLoader(loader, _target, getRenamedColumns(), allowLineageColumns(), null);
675-
}
674+
// Issue 53804: When updating or adding samples across different sample types, the strings 'Yes' and 'No' are converted to their boolean values
675+
if (loader != null && optionParamsMap != null && optionParamsMap.getOrDefault(Params.crossTypeImport, false))
676+
loader.setInferTypes(false);
676677

677-
public static void configureLoader(DataLoader loader, @Nullable TableInfo target, @Nullable Map<String, String> renamedColumns, boolean allowLineageColumns, @Nullable Set<String> lineageAliasNames) throws IOException
678-
{
679678
//apply known columns so loader can do better type conversion
680679
if (loader != null && target != null)
681680
loader.setKnownColumns(target.getColumns());

api/src/org/labkey/api/query/QueryImportPipelineJob.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public void run()
294294

295295
loader = DataLoader.get().createLoader(_importContextBuilder.getPrimaryFile(), _importContextBuilder.getFileContentType(), _importContextBuilder.isHasColumnHeaders(), null, null);
296296

297-
AbstractQueryImportAction.configureLoader(loader, target, _importContextBuilder.getRenamedColumns(), _importContextBuilder.allowLineageColumns(), _importContextBuilder.getLineageImportAliases());
297+
AbstractQueryImportAction.configureLoader(loader, target, _importContextBuilder.getRenamedColumns(), _importContextBuilder.allowLineageColumns(), _importContextBuilder.getLineageImportAliases(), _importContextBuilder.getOptionParamsMap());
298298

299299
TransactionAuditProvider.TransactionAuditEvent auditEvent = null;
300300

experiment/src/org/labkey/experiment/ExpDataIterators.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2555,7 +2555,7 @@ private int _importSplitFile(TypeData typeData, File splitFile, Container dataCo
25552555
else
25562556
aliasNames = new CaseInsensitiveHashSet(((ExpDataClass) typeData.dataType).getImportAliases().keySet());
25572557
// We do not need to configure the loader for renamed columns as that has been taken care of when writing the file.
2558-
configureLoader(loader, dataTable, null, true, aliasNames);
2558+
configureLoader(loader, dataTable, null, true, aliasNames, null /* Not needed since partition is not a cross type import*/);
25592559
if (loader instanceof TabLoader tabLoader)
25602560
tabLoader.setIncludeComments(true); // don't skip lines that starts with "#" (if the original file is Excel)
25612561
return updateService.loadRows(_user, dataContainer, loader, _context, null);

experiment/src/org/labkey/experiment/controllers/exp/ExperimentController.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4502,13 +4502,6 @@ protected JSONObject createSuccessResponse(int rowCount)
45024502
return json;
45034503
}
45044504

4505-
@Override
4506-
protected void configureLoader(DataLoader loader) throws IOException
4507-
{
4508-
if (getOptionParamValue(Params.crossTypeImport))
4509-
loader.setInferTypes(false);
4510-
configureLoader(loader, _target, getRenamedColumns(), allowLineageColumns(), getLineageImportAliases());
4511-
}
45124505
}
45134506

45144507
public abstract static class AbstractExpDataImportAction extends AbstractQueryImportAction<QueryForm>
@@ -4667,12 +4660,6 @@ public void addNavTrail(NavTree root)
46674660
root.addChild("Import Data");
46684661
}
46694662

4670-
@Override
4671-
protected void configureLoader(DataLoader loader) throws IOException
4672-
{
4673-
configureLoader(loader, _target, getRenamedColumns(), allowLineageColumns(), getLineageImportAliases());
4674-
}
4675-
46764663
}
46774664

46784665
@RequiresPermission(UpdatePermission.class)

0 commit comments

Comments
 (0)