rusackas commented on code in PR #42591:
URL: https://github.com/apache/superset/pull/42591#discussion_r3679175679
##########
superset-frontend/plugins/preset-chart-deckgl/src/layers/Polygon/transformProps.test.ts:
##########
@@ -529,4 +529,48 @@ describe('Polygon transformProps', () => {
expect(features[0]?.extraProps?.['SUM(population)']).toBe(50000);
expect(features[0]?.metrics?.['SUM(population)']).toBe(50000);
});
+
+ // Regression test for #33669: a boundary column literally named "polygon"
+ // (the same key this transform uses internally for the parsed geometry)
+ // reportedly broke rendering, because the raw column value could
+ // theoretically collide with the `polygon` key this function builds on
+ // each feature. `line_column` is excluded before spreading a record's
+ // other properties onto the feature, and the parsed `polygon` key is
+ // assigned last in the returned object literal, so it should always win
+ // over anything copied from the raw record, even when they share a name.
+ test('should correctly parse polygon geometry when the boundary column is
itself named "polygon"', () => {
+ const collidingColumnNameProps = {
+ ...mockChartProps,
+ rawFormData: {
+ ...mockChartProps.rawFormData,
+ line_column: 'polygon',
+ },
+ queriesData: [
+ {
+ data: [
+ {
+ polygon: JSON.stringify([
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ ]),
+ population: 50000,
+ },
+ ],
+ },
+ ],
+ };
+
+ const result = transformProps(collidingColumnNameProps as ChartProps);
+ const features = result.payload.data.features as PolygonFeature[];
+
+ expect(features).toHaveLength(1);
+ expect(features[0]?.polygon).toEqual([
+ [-122.4, 37.8],
+ [-122.3, 37.8],
+ [-122.3, 37.9],
+ [-122.4, 37.9],
+ ]);
Review Comment:
That's existing behavior in `transformProps`, not something this PR touches,
it's test-only. Preserving a separate raw value for the tooltip/click case
would be a real change, worth its own issue if it's actually causing problems
in practice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]