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
@@ -7,7 +7,8 @@
|
||||
//
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
import { getEpoch, getGCD, getMod, quote_ident, parseFuncParams, getRandomInt, sprintf } from 'sources/utils';
|
||||
import { getEpoch, getGCD, getMod, quote_ident, parseFuncParams,
|
||||
getRandomInt, sprintf, CSVToArray } from 'sources/utils';
|
||||
|
||||
describe('getEpoch', function () {
|
||||
it('should return non zero', function () {
|
||||
@@ -168,3 +169,25 @@ describe('sprintf', function () {
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('CSVToArray', function() {
|
||||
it('simple input single record', function() {
|
||||
expect(CSVToArray('a,b')).toEqual([['a', 'b']]);
|
||||
});
|
||||
|
||||
it('simple input delimeter change', function() {
|
||||
expect(CSVToArray('"a";"b"', ';')).toEqual([['a', 'b']]);
|
||||
});
|
||||
|
||||
it('simple input multi records', function() {
|
||||
expect(CSVToArray('"a","b"\n"c","d"')).toEqual([['a', 'b'], ['c', 'd']]);
|
||||
});
|
||||
|
||||
it('multiline input containing double quotes', function() {
|
||||
expect(CSVToArray('"hello ""a\nb""","c"')).toEqual([['hello "a\nb"','c']]);
|
||||
});
|
||||
|
||||
it('multiline input containing single quotes', function() {
|
||||
expect(CSVToArray('\'hello \'\'a\nb\'\'\',\'c\'', ',', '\'')).toEqual([['hello \'a\nb\'','c']]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user