[pgAdmin][RM4459] Copying cell from query result table wraps "bigint" value in quotes

Aditya Toshniwal <[email protected]>
Newsgroups gmane.comp.db.postgresql.pgadmin.devel
Message-ID <CAM9w-_mJ8QQgo45xcx0QJuCBuEvETO0PmU6SmyA9-FPPLmpc_Q@mail.gmail.com>
Hi Hackers,

Attached is the patch to fix bigint (numeric cols) copying issue which adds
redundant quotes.

Kindly review.

-- 
Thanks and Regards,
Aditya Toshniwal
Sr. Software Engineer | EnterpriseDB India | Pune
"Don't Complain about Heat, Plant a TREE"
RM4459.patch (application/octet-stream, 4.7 KB)
diff --git a/web/pgadmin/static/js/selection/range_boundary_navigator.js b/web/pgadmin/static/js/selection/range_boundary_navigator.js
index aed5ae60c..f1416b987 100644
--- a/web/pgadmin/static/js/selection/range_boundary_navigator.js
+++ b/web/pgadmin/static/js/selection/range_boundary_navigator.js
@@ -7,8 +7,8 @@
 //
 //////////////////////////////////////////////////////////////
 
-define(['sources/selection/range_selection_helper'],
-  function (RangeSelectionHelper) {
+define(['sources/selection/range_selection_helper', 'json-bignumber'],
+  function (RangeSelectionHelper, JSONBigNumber) {
     return {
       getUnion: function (allRanges) {
         if (_.isEmpty(allRanges)) {
@@ -135,12 +135,13 @@ define(['sources/selection/range_selection_helper'],
 
       csvCell: function (data, columnDefinitions, CSVOptions, rowId, colId) {
         var val = data[rowId][columnDefinitions[colId].field],
+          cell_type = columnDefinitions[colId].cell || '',
           quoting = CSVOptions.quoting || 'strings',
           quote_char = CSVOptions.quote_char || '"';
 
         if (quoting == 'all') {
           if (val && _.isObject(val)) {
-            val = quote_char + JSON.stringify(val) + quote_char;
+            val = quote_char + JSONBigNumber.stringify(val) + quote_char;
           } else if (val) {
             val = quote_char + val.toString() + quote_char;
           } else if (_.isNull(val) || _.isUndefined(val)) {
@@ -149,8 +150,8 @@ define(['sources/selection/range_selection_helper'],
         }
         else if(quoting == 'strings') {
           if (val && _.isObject(val)) {
-            val = quote_char + JSON.stringify(val) + quote_char;
-          } else if (val && typeof val != 'number' && typeof val != 'boolean') {
+            val = quote_char + JSONBigNumber.stringify(val) + quote_char;
+          } else if (val && cell_type != 'number' && cell_type != 'boolean') {
             val = quote_char + val.toString() + quote_char;
           } else if (_.isNull(val) || _.isUndefined(val)) {
             val = '';
diff --git a/web/pgadmin/static/js/slickgrid/editors.js b/web/pgadmin/static/js/slickgrid/editors.js
index 22bd86bae..9852d7398 100644
--- a/web/pgadmin/static/js/slickgrid/editors.js
+++ b/web/pgadmin/static/js/slickgrid/editors.js
@@ -411,6 +411,7 @@ import gettext from 'sources/gettext';
           $input.addClass('pg-text-invalid');
           return {
             valid: false,
+            msg: e.message,
           };
         }
       }
diff --git a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
index 5bfcc3487..ee370a262 100644
--- a/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
+++ b/web/pgadmin/tools/sqleditor/static/js/sqleditor.js
@@ -768,6 +768,7 @@ define('tools.querytool', [
           display_name: c.display_name,
           column_type: c.column_type,
           column_type_internal: c.column_type_internal,
+          cell: c.cell,
           not_null: c.not_null,
           has_default_val: c.has_default_val,
           is_array: c.is_array,
diff --git a/web/regression/javascript/selection/range_boundary_navigator_spec.js b/web/regression/javascript/selection/range_boundary_navigator_spec.js
index bdc79999f..0a3fa3f15 100644
--- a/web/regression/javascript/selection/range_boundary_navigator_spec.js
+++ b/web/regression/javascript/selection/range_boundary_navigator_spec.js
@@ -139,9 +139,9 @@ describe('RangeBoundaryNavigator', function () {
         {'id':3, 'animal':'cougar', 'size':'9'},
         {'id':4, 'animal':'tiger', 'size':'10'}];
 
-      columnDefinitions = [{name: 'id', field: 'id', pos: 0},
-        {name: 'animal', field: 'animal', pos: 1},
-        {name: 'size', field: 'size', pos: 2}];
+      columnDefinitions = [{name: 'id', field: 'id', pos: 0, cell:'number'},
+        {name: 'animal', field: 'animal', pos: 1, cell:'string'},
+        {name: 'size', field: 'size', pos: 2, cell:'string'}];
       ranges = [new Slick.Range(0, 0, 0, 2), new Slick.Range(3, 0, 3, 2)];
 
       CSVOptions = [{'quoting': 'all', 'quote_char': '"', 'field_separator': ','},
@@ -166,9 +166,9 @@ describe('RangeBoundaryNavigator', function () {
     describe('when there is an extra column with checkboxes', function () {
       beforeEach(function () {
         columnDefinitions = [{name: 'not-a-data-column'},
-          {name: 'id', field: 'id', pos: 0},
-          {name: 'animal', field: 'animal', pos: 1},
-          {name: 'size', field: 'size',pos: 2}];
+          {name: 'id', field: 'id', pos: 0, cell:'number'},
+          {name: 'animal', field: 'animal', pos: 1, cell:'string'},
+          {name: 'size', field: 'size',pos: 2, cell:'string'}];
         ranges = [new Slick.Range(0, 0, 0, 3), new Slick.Range(3, 0, 3, 3)];
       });
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.