mirror of
https://github.com/apache/superset.git
synced 2026-04-23 01:55:09 +00:00
fix(pivot-table): safely cast numeric strings to numbers for date formatting (#38953)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
GitHub
parent
e0a0a22542
commit
f1cd1ae710
@@ -269,6 +269,11 @@ function sortHierarchicalObject(
|
||||
return result;
|
||||
}
|
||||
|
||||
function convertToNumberIfNumeric(value: string): string | number {
|
||||
const n = Number(value);
|
||||
return value.trim() !== '' && !Number.isNaN(n) ? n : value;
|
||||
}
|
||||
|
||||
function convertToArray(
|
||||
obj: Map<string, unknown>,
|
||||
rowEnabled: boolean | undefined,
|
||||
@@ -868,7 +873,7 @@ export class TableRenderer extends Component<
|
||||
);
|
||||
};
|
||||
const headerCellFormattedValue =
|
||||
dateFormatters?.[attrName]?.(colKey[attrIdx]) ?? colKey[attrIdx];
|
||||
dateFormatters?.[attrName]?.(convertToNumberIfNumeric(colKey[attrIdx])) ?? colKey[attrIdx];
|
||||
const { backgroundColor, color } = getCellColor(
|
||||
[attrName],
|
||||
headerCellFormattedValue,
|
||||
@@ -1111,7 +1116,7 @@ export class TableRenderer extends Component<
|
||||
: null;
|
||||
|
||||
const headerCellFormattedValue =
|
||||
dateFormatters?.[rowAttrs[i]]?.(r) ?? r;
|
||||
dateFormatters?.[rowAttrs[i]]?.(convertToNumberIfNumeric(r)) ?? r;
|
||||
|
||||
const { backgroundColor, color } = getCellColor(
|
||||
[rowAttrs[i]],
|
||||
|
||||
Reference in New Issue
Block a user