Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sqllab): missing zero values while copy-to-clipboard #21153

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion superset-frontend/src/utils/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ export function prepareCopyToClipboardTabularData(data, columns) {
// JavaScript does not maintain the order of a mixed set of keys (i.e integers and strings)
// the below function orders the keys based on the column names.
const key = columns[j].name || columns[j];
if (data[i][key]) {
if (key in data[i]) {
row[j] = data[i][key];
} else {
row[j] = data[i][parseFloat(key)];
Expand Down
10 changes: 10 additions & 0 deletions superset-frontend/src/utils/common.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ describe('utils/common', () => {
'lorem\tipsum\t\ndolor\tsit\tamet\n',
);
});
it('includes 0 values', () => {
const array = [
{ column1: 0, column2: 0 },
{ column1: 1, column2: -1, 0: 0 },
];
const column = ['column1', 'column2', '0'];
expect(prepareCopyToClipboardTabularData(array, column)).toEqual(
'0\t0\t\n1\t-1\t0\n',
);
});
});
describe('applyFormattingToTabularData', () => {
it('does not mutate empty array', () => {
Expand Down