Don't quote bigints when copying them from the Query Tool results grid. Fixes #4459

This commit is contained in:
Aditya Toshniwal 2019-10-25 11:53:39 +01:00 committed by Dave Page
parent 4125360dfb
commit 6d7ff9444a
6 changed files with 251 additions and 344 deletions

View File

@ -20,5 +20,6 @@ Bug fixes
| `Issue #3789 <https://redmine.postgresql.org/issues/3789>`_ - Ensure context menus never get hidden below the menu bar.
| `Issue #3913 <https://redmine.postgresql.org/issues/3913>`_ - Ensure the correct "running at" agent is shown when a pgAgent job is executing.
| `Issue #4459 <https://redmine.postgresql.org/issues/4459>`_ - Don't quote bigints when copying them from the Query Tool results grid.
| `Issue #4845 <https://redmine.postgresql.org/issues/4845>`_ - Fixed potential error in the properties dialog for the Code tab.
| `Issue #4850 <https://redmine.postgresql.org/issues/4850>`_ - Fixed an issue where Datetimepicker control opens when clicking on the label.

View File

@ -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 = '';

View File

@ -411,6 +411,7 @@ import gettext from 'sources/gettext';
$input.addClass('pg-text-invalid');
return {
valid: false,
msg: e.message,
};
}
}

View File

@ -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,

View File

@ -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)];
});

File diff suppressed because it is too large Load Diff