aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Ahlborn <jtahlborn@yahoo.com>2014-09-29 22:10:43 +0000
committerJames Ahlborn <jtahlborn@yahoo.com>2014-09-29 22:10:43 +0000
commitf17433f2de69b70a89064eb88b543d5e51c61460 (patch)
treecaf515d15e01bd3f4833f76eac2b12d937603b7e
parent364584d16a48230e6dadc20d7f90fa910333de85 (diff)
downloadjackcess-f17433f2de69b70a89064eb88b543d5e51c61460.tar.gz
jackcess-f17433f2de69b70a89064eb88b543d5e51c61460.zip
fix regression where empty memo values are returned as null (issue 110)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@884 f203690c-595d-4dc9-a70b-905162fa7fd2
-rw-r--r--src/changes/changes.xml3
-rw-r--r--src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java5
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java19
-rw-r--r--src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java20
4 files changed, 44 insertions, 3 deletions
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index affaa5c..80de3bc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -8,6 +8,9 @@
<action dev="jahlborn" type="fix" system="SourceForge2" issue="109">
IndexCursor can early exit when searching based on indexed values.
</action>
+ <action dev="jahlborn" type="fix" system="SourceForge2" issue="110">
+ Fix regression where empty memo values are returned as null.
+ </action>
</release>
<release version="2.0.5" date="2014-09-17">
<action dev="jahlborn" type="add">
diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java b/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java
index b648a6a..89accff 100644
--- a/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java
+++ b/src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java
@@ -234,9 +234,12 @@ class LongValueColumnImpl extends ColumnImpl
throws IOException
{
byte[] binData = readLongValue(lvalDefinition);
- if((binData == null) || (binData.length == 0)) {
+ if(binData == null) {
return null;
}
+ if(binData.length == 0) {
+ return "";
+ }
return decodeTextValue(binData);
}
diff --git a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
index a9178fe..a25c6e8 100644
--- a/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
@@ -565,6 +565,8 @@ public class DatabaseTest extends TestCase
table.addRow(testStr, testStr, null);
table.addRow(testStr, longMemo, oleValue);
+ table.addRow("", "", new byte[0]);
+ table.addRow(null, null, null);
table.reset();
@@ -580,6 +582,18 @@ public class DatabaseTest extends TestCase
assertEquals(longMemo, row.get("B"));
assertTrue(Arrays.equals(oleValue, row.getBytes("C")));
+ row = table.getNextRow();
+
+ assertEquals("", row.get("A"));
+ assertEquals("", row.get("B"));
+ assertTrue(Arrays.equals(new byte[0], row.getBytes("C")));
+
+ row = table.getNextRow();
+
+ assertNull(row.get("A"));
+ assertNull(row.get("B"));
+ assertNull(row.getBytes("C"));
+
db.close();
}
}
@@ -1565,7 +1579,10 @@ public class DatabaseTest extends TestCase
for(Map<String, Object> row : cursor) {
foundTable.add(row);
}
- assertEquals(expectedTable, foundTable);
+ assertEquals(expectedTable.size(), foundTable.size());
+ for(int i = 0; i < expectedTable.size(); ++i) {
+ assertEquals(expectedTable.get(i), foundTable.get(i));
+ }
}
public static RowImpl createExpectedRow(Object... rowElements) {
diff --git a/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java b/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java
index 26b2390..bbcd08c 100644
--- a/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java
+++ b/src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java
@@ -102,6 +102,8 @@ public class CalcFieldTest extends TestCase
t.addRow(Column.AUTO_NUMBER, "foo", "1_foo", longStr, true, 2, bd1);
t.addRow(Column.AUTO_NUMBER, "bar", "2_bar", longStr, false, -37, bd2);
+ t.addRow(Column.AUTO_NUMBER, "", "", "", false, 0, BigDecimal.ZERO);
+ t.addRow(Column.AUTO_NUMBER, null, null, null, null, null, null);
List<? extends Map<String, Object>> expectedRows =
createExpectedTable(
@@ -120,7 +122,23 @@ public class CalcFieldTest extends TestCase
"calc_memo", longStr,
"calc_bool", false,
"calc_long", -37,
- "calc_numeric", bd2));
+ "calc_numeric", bd2),
+ createExpectedRow(
+ "id", 3,
+ "data", "",
+ "calc_text", "",
+ "calc_memo", "",
+ "calc_bool", false,
+ "calc_long", 0,
+ "calc_numeric", BigDecimal.ZERO),
+ createExpectedRow(
+ "id", 4,
+ "data", null,
+ "calc_text", null,
+ "calc_memo", null,
+ "calc_bool", null,
+ "calc_long", null,
+ "calc_numeric", null));
assertTable(expectedRows, t);