PT-1554 Test fixes for pt-archiver

This commit is contained in:
Carlos Salguero
2018-05-23 10:59:50 -03:00
parent 6679596b3b
commit f0c947d9cf
2 changed files with 11 additions and 6 deletions

View File

@@ -7156,10 +7156,16 @@ sub escape {
return join($fields_separated_by, map {
s/([\t\n\\])/\\$1/g if defined $_; # Escape tabs etc
$_ = defined $_ ? $_ : '\N'; # NULL = \N
my $s = defined $_ ? $_ : '\N'; # NULL = \N
# var & ~var will return 0 only for numbers
$_ =~ s/([^\\])"/$1\\"/g if ($_ !~ /^[0-9,.E]+$/ && $optionally_enclosed_by eq '"');
$_ = $optionally_enclosed_by && $_ & ~$_ ? $optionally_enclosed_by."$_".$optionally_enclosed_by : $_;
if ($s !~ /^[0-9,.E]+$/ && $optionally_enclosed_by eq '"') {
$s =~ s/([^\\])"/$1\\"/g;
$s = $optionally_enclosed_by."$s".$optionally_enclosed_by;
}
# $_ =~ s/([^\\])"/$1\\"/g if ($_ !~ /^[0-9,.E]+$/ && $optionally_enclosed_by eq '"');
# $_ = $optionally_enclosed_by && ($_ & ~$_) ? $optionally_enclosed_by."$_".$optionally_enclosed_by : $_;
chomp $s;
$s;
} @$row);
}

View File

@@ -46,7 +46,6 @@ is($output, <<EOF
2\t\\N\t3\t4
3\t2\t3\t\\\t
4\t2\t3\t\\
EOF
, 'File has the right stuff');
`rm -f archive.test.table_1`;
@@ -124,8 +123,8 @@ $output = output(
);
$output = `cat archive.test.table_2`;
is($output, <<EOF
1, 2, 3, "4"
2, "\\N", 3, "4"
1, 2, 3, 4
2, "\\N", 3, 4
3, 2, 3, "\\\t"
4, 2, 3, "\\\n"
5, 2, 3, "Zapp \\"Brannigan"