Skip to content

Commit

Permalink
Prevent duplicated columns in TableModel
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgaya authored Oct 1, 2024
1 parent 1796ec9 commit 5e97a96
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions packages/react-widgets/__tests__/models/TableModel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ jest.mock('@carto/react-workers', () => ({
}
}));

afterEach(() => {
jest.clearAllMocks();
});

describe('getTable', () => {
const tableParams = {
source: {
Expand Down Expand Up @@ -94,5 +98,15 @@ describe('getTable', () => {
hasData: true
});
});

test('prevents column duplicates', async () => {
const data = await getTable({
...tableParams,
columns: ['any-column', 'any-column'],
remoteCalculation: true
});

expect(mockedExecuteModel.mock.calls[0][0].params.column).toEqual(['any-column']);
});
});
});
2 changes: 1 addition & 1 deletion packages/react-widgets/src/models/TableModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function fromRemote(props) {
spatialFilter,
...(searchFilter && { searchFilter }),
params: {
column: columns,
column: [...new Set(columns)],
sortBy,
sortDirection,
limit: rowsPerPage,
Expand Down

0 comments on commit 5e97a96

Please sign in to comment.