From: James Ahlborn Date: Wed, 17 Jun 2015 02:20:58 +0000 (+0000) Subject: handle reading null calculated values, fixes #125 X-Git-Tag: jackcess-2.1.2~4 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b521c2b020a5afa4dbd8517c554cb022a66dde2f;p=jackcess.git handle reading null calculated values, fixes #125 git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@949 f203690c-595d-4dc9-a70b-905162fa7fd2 --- diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 8b3a894..00cfe01 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -4,6 +4,11 @@ Tim McCune + + + Handle reading null calculated values. + + Load linked table info from system table when reading databases with diff --git a/src/main/java/com/healthmarketscience/jackcess/impl/CalculatedColumnUtil.java b/src/main/java/com/healthmarketscience/jackcess/impl/CalculatedColumnUtil.java index 2b7395a..f3fdc21 100644 --- a/src/main/java/com/healthmarketscience/jackcess/impl/CalculatedColumnUtil.java +++ b/src/main/java/com/healthmarketscience/jackcess/impl/CalculatedColumnUtil.java @@ -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)); }