Skip Menu |

This queue is for tickets about the Text-CSV_XS CPAN distribution.

Report information
The Basics
Id: 60136
Status: resolved
Priority: 0/
Queue: Text-CSV_XS

People
Owner: Nobody in particular
Requestors: MSTEVENS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.17
Fixed in: 0.74



Subject: always_quote does not always quote
The following test script: #!/usr/bin/perl use Text::CSV_XS; my $csv=Text::CSV_XS->new({binary=>1,'always_quote'=>1}); my @a=(); push @a,'hi'; push @a,undef; push @a,'end'; $csv->combine(@a); print $csv->string."\n"; outputs: "hi",,"end" The second field with value undef is not quoted! Whereas the documentation suggests "all fields will be quoted".
I've noticed this too, moreover, quote_null doesn't do it either (though I would think it would quote undef, and \0 use Text::CSV_XS; my $t = Text::CSV_XS->new({always_quote=>1,quote_null=>1,binary=>1}); $t->combine(qw/foo bar/,undef,undef,q[baz]); print $t->string; -- Evan Carroll System Lord of the Internets http://www.evancarroll.com
Subject: Re: [rt.cpan.org #60136] always_quote does not always quote
Date: Fri, 17 Sep 2010 20:41:08 +0200
To: bug-Text-CSV_XS [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 17 Sep 2010 14:31:15 -0400, "Evan Carroll via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> I've noticed this too, moreover, quote_null doesn't do it either (though > I would think it would quote undef, and \0 > > use Text::CSV_XS; > my $t = Text::CSV_XS->new ({always_quote=>1,quote_null=>1,binary=>1}); > $t->combine (qw/foo bar/,undef,undef,q[baz]); > print $t->string;
preferably as $t->print (*STDOUT, [qw/foo bar/,undef,undef,q[baz]]); I'll investigate -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Subject: Re: [rt.cpan.org #60136] always_quote does not always quote
Date: Fri, 17 Sep 2010 23:01:06 +0200
To: bug-Text-CSV_XS [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 17 Sep 2010 14:31:15 -0400, "Evan Carroll via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> I've noticed this too, moreover, quote_null doesn't do it either (though > I would think it would quote undef, and \0
No, quote_null has NOTHING to do with the <undef> value. The NULL it refers to doesn't come from DBI land, where a database NULL value is represented as undef. with quote_null being true, ->print ($fh, [ 1, "\0", undef ]); will print 1,""0", and with quote_null being false, it will print 1,"", with a \0 between the quotes The undef value will never be quoted -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/
Subject: Re: [rt.cpan.org #60136] always_quote does not always quote
Date: Thu, 23 Sep 2010 11:09:02 +0200
To: bug-Text-CSV_XS [...] rt.cpan.org
From: "H.Merijn Brand" <h.m.brand [...] xs4all.nl>
On Fri, 17 Sep 2010 14:31:15 -0400, "MSTEVENS via RT" <bug-Text-CSV_XS@rt.cpan.org> wrote: Show quoted text
> The second field with value undef is not quoted! Whereas the > documentation suggests "all fields will be quoted".
As this has never been the intention, I have changed the docs to state that only *defined* fields are quoted: --8<--- =item always_quote By default the generated fields are quoted only, if they need to, for example, if they contain the separator. If you set this attribute to a TRUE value, then all defined fields will be quoted. This is typically easier to handle in external applications. (Poor creatures who are not using Text::CSV_XS. :-) -->8--- -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using 5.00307 through 5.12 and porting perl5.13.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/