PT-2410 - Removing the enclosed by on \N(Null) values and removing the space existent after the comma

This commit is contained in:
Roberto de Bem
2024-12-21 15:00:37 -03:00
parent 010f05200e
commit d5ec5d9ca8

View File

@@ -6966,7 +6966,7 @@ sub main {
warn "Invalid output format:". $o->get('format');
warn "Using default 'dump' format";
} elsif ($o->get('output-format') || '' eq 'csv') {
$fields_separated_by = ", ";
$fields_separated_by = ",";
$optionally_enclosed_by = '"';
}
my $need_hdr = $o->get('header') && !-f $archive_file;
@@ -7508,7 +7508,7 @@ sub escape {
s/([\t\n\\])/\\$1/g if defined $_; # Escape tabs etc
my $s = defined $_ ? $_ : '\N'; # NULL = \N
# var & ~var will return 0 only for numbers
if ($s !~ /^[0-9,.E]+$/ && $optionally_enclosed_by eq '"') {
if ($s !~ /^[0-9,.E]+$/ && $optionally_enclosed_by eq '"' && $s ne '\N') {
$s =~ s/([^\\])"/$1\\"/g;
$s = $optionally_enclosed_by."$s".$optionally_enclosed_by;
}