Skip to content

Commit 82b6ca7

Browse files
PivotGrid - fix duplicated hierarchy prefix in axis SET and drill-down MDX (T1283598)
1 parent fa5a0e8 commit 82b6ca7

2 files changed

Lines changed: 72 additions & 2 deletions

File tree

packages/devextreme/js/__internal/grids/pivot_grid/xmla_store/m_xmla_store.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,12 @@ class XmlaStore {
233233

234234
if (i < path.length) {
235235
if (isLastDimensionInGroup) {
236-
arg = `(${dataField}.${preparePathValue(path[i], dataField)})`;
236+
const pathValue = path[i];
237+
if (hierarchyName && isString(pathValue) && pathValue.startsWith(`${hierarchyName}.`)) {
238+
arg = `(${pathValue})`;
239+
} else {
240+
arg = `(${dataField}.${preparePathValue(pathValue, dataField)})`;
241+
}
237242
}
238243
} else if (i <= expandAllIndex) {
239244
if (i === 0 && expandAllCount === 0) {
@@ -585,7 +590,12 @@ class XmlaStore {
585590
if (field.hierarchyName && (fields[index + 1] || {}).hierarchyName === field.hierarchyName) {
586591
return;
587592
}
588-
slice.push(`${field.dataField}.${this.preparePathValue(value, field.dataField)}`);
593+
const { hierarchyName } = field;
594+
if (hierarchyName && isString(value) && value.startsWith(`${hierarchyName}.`)) {
595+
slice.push(value);
596+
} else {
597+
slice.push(`${field.dataField}.${this.preparePathValue(value, field.dataField)}`);
598+
}
589599
});
590600
}
591601

packages/devextreme/testing/tests/DevExpress.ui.widgets.pivotGrid/store.xmla.tests.js

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,66 @@ QUnit.module('Hierarchies', stubsEnvironment, () => {
494494
);
495495
});
496496

497+
QUnit.test('T1283598. Axis SET should not duplicate hierarchy prefix when expanded path value is a full unique name', function(assert) {
498+
this.store.load({
499+
columns: [{ dataField: '[Active Month].[Active Month]' }],
500+
rows: [
501+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
502+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Sub Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
503+
{ dataField: '[Product].[Product Nbr]' }
504+
],
505+
values: [{ dataField: '[Measures].[Members]', caption: 'Members' }],
506+
rowExpandedPaths: [
507+
['[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]'],
508+
['[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]', '[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group]']
509+
]
510+
});
511+
const query = this.getQuery();
512+
513+
assert.notStrictEqual(
514+
query.indexOf('([Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group])'),
515+
-1,
516+
'axis SET contains the full unique name once'
517+
);
518+
assert.strictEqual(
519+
query.indexOf('[Product].[Product Purchaser Type].[Purchaser Sub Type].[Product].[Product Purchaser Type]'),
520+
-1,
521+
'axis SET does not duplicate the hierarchy prefix'
522+
);
523+
});
524+
525+
QUnit.test('T1283598. Drill-down WHERE slice should not duplicate hierarchy prefix when path value is a full unique name', function(assert) {
526+
this.store.getDrillDownItems({
527+
columns: [{ dataField: '[Active Month].[Active Month]' }],
528+
rows: [
529+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
530+
{ dataField: '[Product].[Product Purchaser Type].[Purchaser Sub Type]', hierarchyName: '[Product].[Product Purchaser Type]' },
531+
{ dataField: '[Product].[Product Nbr]' }
532+
],
533+
values: [{ dataField: '[Measures].[Members]', caption: 'Members' }]
534+
}, {
535+
columnPath: [],
536+
rowPath: [
537+
'[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial]',
538+
'[Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group]'
539+
],
540+
dataIndex: 0,
541+
maxRowCount: 100
542+
});
543+
const query = this.getQuery();
544+
545+
assert.notStrictEqual(
546+
query.indexOf('WHERE ([Product].[Product Purchaser Type].[Purchaser Type].&[Commercial].&[Group])'),
547+
-1,
548+
'drill-down WHERE slice contains the full unique name once'
549+
);
550+
assert.strictEqual(
551+
query.indexOf('[Product].[Product Purchaser Type].[Purchaser Sub Type].[Product].[Product Purchaser Type]'),
552+
-1,
553+
'drill-down WHERE slice does not duplicate the hierarchy prefix'
554+
);
555+
});
556+
497557
QUnit.test('Hierarchy. Expand child when opposite axis expanded on several levels', function(assert) {
498558
this.store.load({
499559
columns: [{

0 commit comments

Comments
 (0)