mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Fixed an issue where copying and pasting a cell with multiple line data
will result in multiple rows. Fixes #5526 Fixed an old issue where quotes are not escaped when copying the cells. As per CSV standards, if the string is in double quotes and there are double quotes inside the string then they should be escaped with extra double-quotes.
This commit is contained in:
committed by
Akshay Joshi
parent
9d006d0ec5
commit
26a758a0d6
@@ -10,7 +10,7 @@
|
||||
define('tools.querytool', [
|
||||
'sources/gettext', 'sources/url_for', 'jquery', 'jquery.ui',
|
||||
'jqueryui.position', 'underscore', 'pgadmin.alertifyjs',
|
||||
'sources/pgadmin', 'backbone', 'bundled_codemirror',
|
||||
'sources/pgadmin', 'backbone', 'bundled_codemirror', 'sources/utils',
|
||||
'pgadmin.misc.explain',
|
||||
'sources/selection/grid_selector',
|
||||
'sources/selection/active_cell_capture',
|
||||
@@ -48,7 +48,7 @@ define('tools.querytool', [
|
||||
'pgadmin.browser',
|
||||
'pgadmin.tools.user_management',
|
||||
], function(
|
||||
gettext, url_for, $, jqueryui, jqueryui_position, _, alertify, pgAdmin, Backbone, codemirror,
|
||||
gettext, url_for, $, jqueryui, jqueryui_position, _, alertify, pgAdmin, Backbone, codemirror, pgadminUtils,
|
||||
pgExplain, GridSelector, ActiveCellCapture, clipboard, copyData, RangeSelectionHelper, handleQueryOutputKeyboardEvent,
|
||||
XCellSelectionModel, setStagedRows, SqlEditorUtils, ExecuteQuery, httpErrorHandler, FilterHandler,
|
||||
GeometryViewer, historyColl, queryHist, querySources,
|
||||
@@ -3739,23 +3739,18 @@ define('tools.querytool', [
|
||||
|
||||
// This function will paste the selected row.
|
||||
_paste_row: function() {
|
||||
|
||||
var self = this;
|
||||
let rowsText = clipboard.getTextFromClipboard();
|
||||
let copied_rows = rowsText.split('\n');
|
||||
let copied_rows = pgadminUtils.CSVToArray(rowsText, self.preferences.results_grid_field_separator, self.preferences.results_grid_quote_char);
|
||||
// Do not parse row if rows are copied with headers
|
||||
if(pgAdmin.SqlEditor.copiedInOtherSessionWithHeaders) {
|
||||
copied_rows = copied_rows.slice(1);
|
||||
}
|
||||
copied_rows = copied_rows.reduce((partial, item) => {
|
||||
copied_rows = copied_rows.reduce((partial, values) => {
|
||||
// split each row with field separator character
|
||||
const values = item.split(self.preferences.results_grid_field_separator);
|
||||
let row = {};
|
||||
for (let col in self.columns) {
|
||||
let v = null;
|
||||
if (values.length > col) {
|
||||
v = values[col].replace(new RegExp(`^\\${self.preferences.results_grid_quote_char}`), '').replace(new RegExp(`\\${self.preferences.results_grid_quote_char}$`), '');
|
||||
}
|
||||
let v = values[col];
|
||||
|
||||
// set value to default or null depending on column metadata
|
||||
if(v === '') {
|
||||
|
||||
Reference in New Issue
Block a user