commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Georg Tsakumagos (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (CSV-93) Allow the handling of NULL values
Date Tue, 24 Mar 2015 17:39:54 GMT

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

Georg Tsakumagos edited comment on CSV-93 at 3/24/15 5:39 PM:
--------------------------------------------------------------

The current implementation is in conflict with the specification. It is not possible to distinguish
between an empty string and a null value. I've reviewed the unittest and it does not test
with an empty string. The generic strategy to map null values to a configurable string is
very generic but leads to problems interpreting the data.

Thats why i choose the quotes in my fist approach to signal an empty string. Replacing an
null value with "NULL" leads to the problem where the text NULL is allowed data. 

I'am a little bit disapointed. I've provided a complete solution with an unit-test. I'd expect
at least an equivalent test to check the correct implementation. 

Maybe in the next run. 
Meanwhile i'll patch it locally. 


was (Author: geo):
The current state does not honor the specification. It is not possible to distinguish between
an empty string and a null value. The applied solution is not usable in that case. I've reviewed
the unittest and see that it does not test with an empty string. The generic strategy to map
null values to a configurable string is very generic but leads to problems interpreting the
data.

Thats why i choose the semantic way im my fist approach to use the quotes to signal an empty
string. Replacing an null value with an string e.g. NULL leads to the problem where the text
NULL is allowed data.

> Allow the handling of NULL values
> ---------------------------------
>
>                 Key: CSV-93
>                 URL: https://issues.apache.org/jira/browse/CSV-93
>             Project: Commons CSV
>          Issue Type: Improvement
>          Components: Documentation, Parser, Printer
>    Affects Versions: 1.0
>            Reporter: Georg Tsakumagos
>             Fix For: 1.0
>
>         Attachments: CSV-93.diff, patch.txt
>
>
> h5. Requirement
> To use the CSV parser and printer for SQL Dumps it would be nice if they could handle
*null* values. 
> h5. Specification
> To distinguish between an *empty* or *null* value empty values always gets quoted to
denote an empty string. The absence of an quote denotes a *null* value
> h5. Configuration
> To activate the behavior call the method _withNullObjectPatternEnabled_ of the _CSVFormat_
with parameter _true_.
> h5. Modifications
> See attached patch.
> h5. Example
> This example using as base the _DEFAULT_ _CSVFormat_ modified by the NullObjectPattern
behavior.
> || Array-Data || CSV-Data ||
> | \{null,"","A"," "\}; |,"A",""," " |
> | \{"",null,"A"," "\} |"",,"A"," " |
> | \{"","A",null\} |"","A", |
> h5. NULL in DBMS proprietary CSV formats
> || Product || Strategy || Documentation / Link ||
> | PostgreSQL | If NULL should be preserved all non NULL values gets quoted | [PostgreSQL
8.1 Manual|http://www.postgresql.org/docs/8.1/static/sql-copy.html] |
> | MySQL | NULL Values will be replaced by the letters NULL or escaped by \n | not found,
verified with MySQL Workbench | 
> | MS SQL | NULL values will be exported as empty strings (no quotes). Strings will be
quoted if needed. Import can interpret them as null | [MSDN|http://msdn.microsoft.com/en-us//library/ms187887]
| 
> | Oracle | NULL Values will be replaced by the letters NULL | [Manual|http://docs.oracle.com/cd/B25329_01/doc/admin.102/b25107/impexp.htm]
|



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

Mime
View raw message