From 3e65c38c616a27129a29382f1329a2c10d648731 Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Wed, 18 Dec 2024 12:34:33 -0500 Subject: [PATCH 1/2] fix(picking): Avoid case changes on column names --- src/widget-sources/widget-base-source.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/widget-sources/widget-base-source.ts b/src/widget-sources/widget-base-source.ts index 3768aba..7e7e4f3 100644 --- a/src/widget-sources/widget-base-source.ts +++ b/src/widget-sources/widget-base-source.ts @@ -142,9 +142,8 @@ export abstract class WidgetBaseSource { tileResolution: tileResolution || DEFAULT_TILE_RESOLUTION, }, opts: {abortController}, - }).then((res: FeaturesModelResponse) => ({ - rows: normalizeObjectKeys(res.rows), - })); + // Avoid `normalizeObjectKeys()`, which changes column names. + }).then(({rows}: FeaturesModelResponse) => ({rows})); } /**************************************************************************** From b93f850af64e83e0c1e480c48dc5965cfac5048c Mon Sep 17 00:00:00 2001 From: Don McCurdy Date: Wed, 18 Dec 2024 12:37:12 -0500 Subject: [PATCH 2/2] add test --- .../widget-sources/widget-base-source.test.ts | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/test/widget-sources/widget-base-source.test.ts b/test/widget-sources/widget-base-source.test.ts index 0f3350b..5b651f8 100644 --- a/test/widget-sources/widget-base-source.test.ts +++ b/test/widget-sources/widget-base-source.test.ts @@ -235,9 +235,24 @@ test('getFeatures', async () => { }); const expectedRows = [ - {_carto_feature_id: 'a', name: 'Veggie Mart', revenue: 1200}, - {_carto_feature_id: 'b', name: 'EZ Drive Thru', revenue: 400}, - {_carto_feature_id: 'c', name: "Buddy's Convenience", revenue: 800}, + { + _carto_feature_id: 'a', + name: 'Veggie Mart', + revenue: 1200, + CaseSensitive: 1, + }, + { + _carto_feature_id: 'b', + name: 'EZ Drive Thru', + revenue: 400, + CaseSensitive: 2, + }, + { + _carto_feature_id: 'c', + name: "Buddy's Convenience", + revenue: 800, + CaseSensitive: 3, + }, ]; const mockFetch = vi @@ -248,7 +263,7 @@ test('getFeatures', async () => { vi.stubGlobal('fetch', mockFetch); const actualFeatures = await widgetSource.getFeatures({ - columns: ['_carto_feature_id', 'name', 'revenue'], + columns: ['_carto_feature_id', 'name', 'revenue', 'CaseSensitive'], featureIds: ['a', 'b', 'c'], dataType: 'points', }); @@ -261,7 +276,7 @@ test('getFeatures', async () => { type: 'test', source: 'test-data', params: JSON.stringify({ - columns: ['_carto_feature_id', 'name', 'revenue'], + columns: ['_carto_feature_id', 'name', 'revenue', 'CaseSensitive'], dataType: 'points', featureIds: ['a', 'b', 'c'], limit: 1000,