]> source.dussan.org Git - jackcess.git/commitdiff
fix regression where empty memo values are returned as null (issue 110)
authorJames Ahlborn <jtahlborn@yahoo.com>
Mon, 29 Sep 2014 22:10:43 +0000 (22:10 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Mon, 29 Sep 2014 22:10:43 +0000 (22:10 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@884 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/main/java/com/healthmarketscience/jackcess/impl/LongValueColumnImpl.java
src/test/java/com/healthmarketscience/jackcess/DatabaseTest.java
src/test/java/com/healthmarketscience/jackcess/impl/CalcFieldTest.java

index affaa5c1d0f2fa6abf76dd6999375639bb120e77..80de3bc5ab40de95937a312dd39d8e64cd8b6b5c 100644 (file)
@@ -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">
index b648a6a08f2c24a329ed13a6cabbd5ca00b74e4e..89accffca791dd532f01dd966639adf2e7652d2b 100644 (file)
@@ -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);
   }
 
index a9178feed3808498c4a17fdbf4042ab390da871e..a25c6e81d9e4f23f861d7c6ca044ea41e5f66a5b 100644 (file)
@@ -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) {
index 26b2390fe594d313c90d737849ca713ec2f56f75..bbcd08c605c696589b56c2e60193760630a0a4aa 100644 (file)
@@ -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);