You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by el...@apache.org on 2022/09/20 20:50:24 UTC

[superset] 14/29: fix(sqllab): missing zero values while copy-to-clipboard (#21153)

This is an automated email from the ASF dual-hosted git repository.

elizabeth pushed a commit to branch 2.0-test
in repository https://gitbox.apache.org/repos/asf/superset.git

commit 9337dec038cf03ea44ba4521fb16f7e32a672b88
Author: JUST.in DO IT <ju...@airbnb.com>
AuthorDate: Fri Aug 26 14:28:48 2022 -0700

    fix(sqllab): missing zero values while copy-to-clipboard (#21153)
    
    (cherry picked from commit 4e23d62d4f3714808af8b915caa5790900688526)
---
 superset-frontend/src/utils/common.js       |  2 +-
 superset-frontend/src/utils/common.test.jsx | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/superset-frontend/src/utils/common.js b/superset-frontend/src/utils/common.js
index 603ec7c549..400a7d05e0 100644
--- a/superset-frontend/src/utils/common.js
+++ b/superset-frontend/src/utils/common.js
@@ -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)];
diff --git a/superset-frontend/src/utils/common.test.jsx b/superset-frontend/src/utils/common.test.jsx
index 6c73b1011c..571e493add 100644
--- a/superset-frontend/src/utils/common.test.jsx
+++ b/superset-frontend/src/utils/common.test.jsx
@@ -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', () => {