Skip to content

Commit 692c4ae

Browse files
fix(client-core): Remove default value in table pivot (#9869)
* Remove defaulting to empty string in tablePivot * Added a regression test
1 parent 619eb90 commit 692c4ae

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

packages/cubejs-client-core/src/ResultSet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -784,7 +784,7 @@ export default class ResultSet<T extends Record<string, any> = any> {
784784
[
785785
...(normalizedPivotConfig.x).map((key, index): [string, string | number] => [
786786
key,
787-
xValues[index] ?? ''
787+
xValues[index]
788788
]),
789789
...(isMeasuresPresent
790790
? yValuesArray.map(([yValues, measure]): [string, string | number] => [

packages/cubejs-client-core/test/ResultSet.test.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1807,5 +1807,28 @@ describe('ResultSet', () => {
18071807
]
18081808
);
18091809
});
1810+
1811+
test('keeps null values on non-matching rows', () => {
1812+
const resultSet = new ResultSet({
1813+
query: {
1814+
dimensions: [
1815+
'User.name',
1816+
'Friend.name'
1817+
],
1818+
},
1819+
data: [
1820+
{
1821+
'User.name': 'Bob',
1822+
'Friend.name': null,
1823+
}
1824+
],
1825+
} as any);
1826+
1827+
expect(resultSet.tablePivot()).toEqual(
1828+
[
1829+
{ 'User.name': 'Bob', 'Friend.name': null },
1830+
]
1831+
);
1832+
});
18101833
});
18111834
});

0 commit comments

Comments
 (0)