[ 
https://issues.apache.org/jira/browse/CSV-203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15734727#comment-15734727
 ] 

Thai H commented on CSV-203:
----------------------------

I don't think this issue should be fixed because 
     # It is a common practice to not quote the NULL values (if a value is 
quoted, it is the real value, not the NULL value)
     # nullString can be configured to include the quoted value if it is really 
needed

More info:

    1. MySQL doc (http://dev.mysql.com/doc/refman/5.7/en/load-data.html)
    {quote}If FIELDS ENCLOSED BY is not empty, a field containing the literal 
word NULL as its value is read as a NULL value. This differs from the word NULL 
enclosed within FIELDS ENCLOSED BY characters, which is read as the string 
'NULL'.{quote}

    2. PostgreSQL doc  
(https://www.postgresql.org/docs/9.2/static/sql-copy.html)
     {quote}Forces quoting to be used for all non-NULL values in each specified 
column. NULL output is never quoted. If * is specified, non-NULL values will be 
quoted in all columns. This option is allowed only in COPY TO, and only when 
using CSV format.{quote}


> withNullString value is printed without quotes when QuoteMode.ALL is specified
> ------------------------------------------------------------------------------
>
>                 Key: CSV-203
>                 URL: https://issues.apache.org/jira/browse/CSV-203
>             Project: Commons CSV
>          Issue Type: Bug
>          Components: Printer
>    Affects Versions: 1.3, 1.4
>            Reporter: Richard Wheeldon
>              Labels: regression
>
> When setting QuoteMode.ALL is set we expect all values to be quoted, even 
> those set as a default. This works in Commons 1.2 but doesn't in 1.4.
> Consider the following program:
> {code}
> import org.apache.commons.csv.QuoteMode;
> import org.apache.commons.csv.CSVFormat;
> import org.apache.commons.csv.CSVPrinter;
> public class CommonsCsvIsSlightlyBroken {
>     
>     public static void main(String[] args) throws Exception {
>         CSVFormat format = CSVFormat.EXCEL
>             .withNullString("N/A")
>             .withIgnoreSurroundingSpaces(true)
>             .withQuoteMode(QuoteMode.ALL);
>         CSVPrinter printer = new CSVPrinter(System.out, format);
>         printer.printRecord(new Object[] { null, "Hello", null, "World" });
>     }
> }
> {code}
> For 1.2 we get quoted output:
> {code}
> richard@kichemaru:~/$ java -cp 
> ~/.m2/repository/org/apache/commons/commons-csv/1.2/commons-csv-1.2.jar:. 
> CommonsCsvIsSlightlyBroken
> "N/A","Hello","N/A","World"
> {code}
> When run with 1.4 we get unquoted output for default fields:
> {code}
> richard@kichemaru:~/$ java -cp 
> ~/.m2/repository/org/apache/commons/commons-csv/1.4/commons-csv-1.4.jar:. 
> CommonsCsvIsSlightlyBroken
> N/A,"Hello",N/A,"World"
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to