Skip to content

Commit 959ab2a

Browse files
ryanjdewMarkLogic Builder
authored andcommitted
DHFPROD-7301: Fix single column export
1 parent ae248b2 commit 959ab2a

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/data-services/entitySearch/exportSearchAsCSV.sjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ xdmp.securityAssert("http://marklogic.com/data-hub/hub-central/privileges/export
2020
const op = require('/MarkLogic/optic');
2121
const search = require('/MarkLogic/appservices/search/search');
2222
const entityLib = require("/data-hub/5/impl/entity-lib.sjs");
23+
const HubUtils = require("/data-hub/5/impl/hub-utils.sjs");
24+
const hubUtils = new HubUtils();
2325
const httpUtils = require("/data-hub/5/impl/http-utils.sjs");
2426

2527
const returnFlags = `<return-aggregates xmlns="http://marklogic.com/appservices/search">false</return-aggregates>
@@ -88,7 +90,8 @@ queryOptions = fn.head(xdmp.unquote(queryOptions)).root;
8890
* Also replacing hyphen with underscore for column names (entity property names), schema names and view names since TDE's do the same.
8991
*/
9092
const simplePropertySet = filterObjectAndArrayTypeProperties(schemaName);
91-
columns = columns.toArray().filter(column => simplePropertySet.has(column)).map(column => replaceHyphenWithUnderscore(column));
93+
// Using Sequence.from
94+
columns = hubUtils.normalizeToArray(columns).filter(column => simplePropertySet.has(column)).map(column => replaceHyphenWithUnderscore(column));
9295
viewName = replaceHyphenWithUnderscore(viewName);
9396
schemaName = replaceHyphenWithUnderscore(schemaName);
9497

marklogic-data-hub/src/test/ml-modules/root/test/suites/data-hub/5/data-services/entitySearch/exportSearchAsCSVTest.sjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,32 @@ function testPlanWithBadSortOrder() {
102102
];
103103
}
104104

105+
function testPlanWithSingleColumn() {
106+
const structuredQuery = xdmp.quote(search.parse(''));
107+
let err = null;
108+
try {
109+
const plan = invokeExportSearchService(
110+
'EntitySearchEntity',
111+
'EntitySearchEntity', 10,
112+
structuredQuery, '',
113+
[],
114+
'searchEntityProp1');
115+
} catch (e) {
116+
err = e;
117+
}
118+
return [
119+
test.assertTrue(err === null, `Exception should not be thrown for single column. ${xdmp.describe(err, Sequence.from([]), Sequence.from([]))}`)
120+
];
121+
}
122+
105123
let assertions = [];
106124
// Test with hub-central-entity-exporter
107125
hubTest.runWithRolesAndPrivileges(['hub-central-entity-exporter'], [], function() {
108126
assertions = []
109127
.concat(testValidAscendingPlan())
110128
.concat(testValidDescendingPlan())
111-
.concat(testPlanWithBadSortOrder());
129+
.concat(testPlanWithBadSortOrder())
130+
.concat(testPlanWithSingleColumn());
112131
});
113132

114133
assertions;

0 commit comments

Comments
 (0)