Skip to content

Commit 452e880

Browse files
committed
Fixed an issue where pasting JSON data type values into the Result Grid caused a syntax error by replacing our custom CSV-to-array conversion code with the PapaParse package. #8296
1 parent 58bb142 commit 452e880

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@
122122
"moment-timezone": "^0.5.34",
123123
"notificar": "^1.0.1",
124124
"notistack": "^3.0.1",
125+
"papaparse": "^5.5.2",
125126
"path-fx": "^2.0.0",
126127
"postcss": "^8.4.31",
127128
"rc-dock": "^3.2.9",

web/pgadmin/tools/sqleditor/static/js/components/QueryToolDataGrid/CopyData.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
//////////////////////////////////////////////////////////////
99
import JSONBigNumber from 'json-bignumber';
1010
import _ from 'lodash';
11+
import Papa from 'papaparse';
1112
import * as clipboard from '../../../../../../static/js/clipboard';
12-
import { CSVToArray } from '../../../../../../static/js/utils';
1313

1414
export default class CopyData {
1515
constructor(options) {
@@ -91,7 +91,14 @@ export default class CopyData {
9191

9292
getCopiedRows() {
9393
let copiedText = clipboard.getFromClipboard();
94-
let copiedRows = CSVToArray(copiedText, this.CSVOptions.field_separator, this.CSVOptions.quote_char);
94+
95+
// Use papaparse to parse the CSV data
96+
const parsedResult = Papa.parse(copiedText, {
97+
delimiter: this.CSVOptions.field_separator,
98+
quoteChar: this.CSVOptions.quote_char,
99+
});
100+
101+
let copiedRows = parsedResult.data;
95102

96103
if(localStorage.getItem('copied-with-headers') == 'true') {
97104
copiedRows = copiedRows.slice(1);

0 commit comments

Comments
 (0)