]> source.dussan.org Git - jackcess.git/commitdiff
handle reading null calculated values, fixes #125
authorJames Ahlborn <jtahlborn@yahoo.com>
Wed, 17 Jun 2015 02:20:58 +0000 (02:20 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Wed, 17 Jun 2015 02:20:58 +0000 (02:20 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@949 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/main/java/com/healthmarketscience/jackcess/impl/CalculatedColumnUtil.java

index 8b3a8942e52d415c2f3a037c62f67c59fa6aaee5..00cfe018527f107da466df9d8534858f79b65199 100644 (file)
@@ -4,6 +4,11 @@
     <author email="javajedi@users.sf.net">Tim McCune</author>
   </properties>
   <body>
+    <release version="2.1.2" date="TBD">
+      <action dev="jahlborn" type="fix" system="SourceForge2" issue="125">
+        Handle reading null calculated values.
+      </action>
+    </release>
     <release version="2.1.1" date="2015-05-14">
       <action dev="jahlborn" type="fix" system="SourceForge2" issue="123">
         Load linked table info from system table when reading databases with
index 2b7395aefc1e95faa3d2f7cd21735782c0233b0f..f3fdc2102afe63eeb6624f42bbdc7aea6a1cf9b8 100644 (file)
@@ -139,7 +139,12 @@ class CalculatedColumnUtil
 
     @Override
     public Object read(byte[] data, ByteOrder order) throws IOException {
-      return super.read(unwrapCalculatedValue(data), order);
+      data = unwrapCalculatedValue(data);
+      if((data.length == 0) && !getType().isVariableLength()) {
+        // apparently "null" values can be written as actual data
+        return null;
+      }
+      return super.read(data, order);
     }
 
     @Override
@@ -173,6 +178,9 @@ class CalculatedColumnUtil
     @Override
     public Object read(byte[] data, ByteOrder order) throws IOException {
       data = unwrapCalculatedValue(data);
+      if(data.length == 0) {
+        return Boolean.FALSE;
+      }
       return ((data[0] != 0) ? Boolean.TRUE : Boolean.FALSE);
     }
 
@@ -266,6 +274,10 @@ class CalculatedColumnUtil
     @Override
     public Object read(byte[] data, ByteOrder order) throws IOException {
       data = unwrapCalculatedValue(data);
+      if(data.length == 0) {
+        // apparently "null" values can be written as actual data
+        return null;
+      }
       return readCalcNumericValue(ByteBuffer.wrap(data).order(order));
     }