Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
1.0
-
None
Description
Requirement
To use the CSV parser and printer for SQL Dumps it would be nice if they could handle null values.
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
Configuration
To activate the behavior call the method withNullObjectPatternEnabled of the CSVFormat with parameter true.
Modifications
See attached patch.
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", |
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 |
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 |
Oracle | NULL Values will be replaced by the letters NULL | Manual |