This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-csv.git
The following commit(s) were added to refs/heads/master by this push:
new 0aa9c47f [CSV-254] POSTGRESQL_CSV cannot parse correctly (null vs
zero-length string)
0aa9c47f is described below
commit 0aa9c47fbd60d67f58361676a6b6d30f319fada6
Author: Gary D. Gregory <[email protected]>
AuthorDate: Sat Jun 21 15:57:55 2025 -0400
[CSV-254] POSTGRESQL_CSV cannot parse correctly (null vs zero-length
string)
Add test
---
pom.xml | 1 +
.../apache/commons/csv/issues/JiraCsv254Test.java | 52 ++++++++++++++++++++++
.../org/apache/commons/csv/CSV-254/csv-254.csv | 3 ++
3 files changed, 56 insertions(+)
diff --git a/pom.xml b/pom.xml
index 45928257..a1eca057 100644
--- a/pom.xml
+++ b/pom.xml
@@ -183,6 +183,7 @@
<exclude>src/test/resources/org/apache/commons/csv/CSV-196/emoji.csv</exclude>
<exclude>src/test/resources/org/apache/commons/csv/CSV-196/japanese.csv</exclude>
<exclude>src/test/resources/org/apache/commons/csv/CSV-213/999751170.patch.csv</exclude>
+
<exclude>src/test/resources/org/apache/commons/csv/CSV-254/csv-254.csv</exclude>
<exclude>src/test/resources/org/apache/commons/csv/CSVFileParser/bom.csv</exclude>
<exclude>src/test/resources/org/apache/commons/csv/CSVFileParser/test.csv</exclude>
<exclude>src/test/resources/org/apache/commons/csv/CSVFileParser/test_default.txt</exclude>
diff --git a/src/test/java/org/apache/commons/csv/issues/JiraCsv254Test.java
b/src/test/java/org/apache/commons/csv/issues/JiraCsv254Test.java
new file mode 100644
index 00000000..629b42ee
--- /dev/null
+++ b/src/test/java/org/apache/commons/csv/issues/JiraCsv254Test.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.commons.csv.issues;
+
+import static org.apache.commons.csv.CsvAssertions.assertValuesEquals;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Iterator;
+
+import org.apache.commons.csv.CSVFormat;
+import org.apache.commons.csv.CSVParser;
+import org.apache.commons.csv.CSVRecord;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests https://issues.apache.org/jira/browse/CSV-254.
+ */
+class JiraCsv254Test {
+
+ @Test
+ void test() throws IOException {
+ final CSVFormat csvFormat = CSVFormat.POSTGRESQL_CSV;
+ try (BufferedReader reader =
Files.newBufferedReader(Paths.get("src/test/resources/org/apache/commons/csv/CSV-254/csv-254.csv"),
+ StandardCharsets.UTF_8); CSVParser parser =
csvFormat.parse(reader)) {
+ final Iterator<CSVRecord> csvRecords = parser.iterator();
+ assertValuesEquals(new String[] { "AA", "33", null },
csvRecords.next());
+ assertValuesEquals(new String[] { "AA", null, "" },
csvRecords.next());
+ assertValuesEquals(new String[] { null, "33", "CC" },
csvRecords.next());
+ }
+ }
+}
diff --git a/src/test/resources/org/apache/commons/csv/CSV-254/csv-254.csv
b/src/test/resources/org/apache/commons/csv/CSV-254/csv-254.csv
new file mode 100644
index 00000000..e7d2972c
--- /dev/null
+++ b/src/test/resources/org/apache/commons/csv/CSV-254/csv-254.csv
@@ -0,0 +1,3 @@
+AA,33,
+AA,,""
+,33,CC