]> source.dussan.org Git - jackcess.git/commitdiff
Access expects a row to be at least big enough to hold all fixed values, even if...
authorJames Ahlborn <jtahlborn@yahoo.com>
Sat, 16 Apr 2011 18:13:20 +0000 (18:13 +0000)
committerJames Ahlborn <jtahlborn@yahoo.com>
Sat, 16 Apr 2011 18:13:20 +0000 (18:13 +0000)
git-svn-id: https://svn.code.sf.net/p/jackcess/code/jackcess/trunk@553 f203690c-595d-4dc9-a70b-905162fa7fd2

src/changes/changes.xml
src/java/com/healthmarketscience/jackcess/Table.java

index a362c23e8737af7bbca8f35accc7849e5ad27045..5d971024e1d86bfb17f0e54031eed769deb2b79a 100644 (file)
         Add support for Access 2010, including new "General" sort order
         (support for long text index entries still needs work).
       </action>
+      <action dev="jahlborn" type="fix" issue="3287626">
+        Access expects a row to be at least big enough to hold all fixed
+        values, even if they are null.
+      </action>
     </release>
     <release version="1.2.3" date="2011-03-05">
       <action dev="jahlborn" type="fix" issue="3181334">
index 77b82d16790642def772c9ac7e4572505dc794ca..880872825e6c88304bf5ff4223611cff3ce2412c 100644 (file)
@@ -1605,45 +1605,52 @@ public class Table
     int fixedDataEnd = fixedDataStart;
     for (Column col : _columns) {
 
-      if(!col.isVariableLength()) {
+      if(col.isVariableLength()) {
+        continue;
+      }
         
-        Object rowValue = rowArray[col.getColumnIndex()];
+      Object rowValue = rowArray[col.getColumnIndex()];
 
-        if (col.getType() == DataType.BOOLEAN) {
+      if (col.getType() == DataType.BOOLEAN) {
         
-          if(Column.toBooleanValue(rowValue)) {
-            //Booleans are stored in the null mask
-            nullMask.markNotNull(col);
-          }
+        if(Column.toBooleanValue(rowValue)) {
+          //Booleans are stored in the null mask
+          nullMask.markNotNull(col);
+        }
+        rowValue = null;
         
-        } else {
-
-          if(col.isAutoNumber() && !isUpdate) {
+      } else if(col.isAutoNumber() && !isUpdate) {
             
-            // ignore given row value, use next autonumber
-            rowValue = col.getAutoNumberGenerator().getNext();
+        // ignore given row value, use next autonumber
+        rowValue = col.getAutoNumberGenerator().getNext();
 
-            // we need to stick this back in the row so that the indexes get
-            // updated correctly (and caller can get the generated value)
-            rowArray[col.getColumnIndex()] = rowValue;
-          }
+        // we need to stick this back in the row so that the indexes get
+        // updated correctly (and caller can get the generated value)
+        rowArray[col.getColumnIndex()] = rowValue;
+      }
           
-          if(rowValue != null) {
+      if(rowValue != null) {
         
-            // we have a value
-            nullMask.markNotNull(col);
+        // we have a value to write
+        nullMask.markNotNull(col);
 
-            //remainingRowLength is ignored when writing fixed length data
-            buffer.position(fixedDataStart + col.getFixedDataOffset());
-            buffer.put(col.write(rowValue, 0));
+        // remainingRowLength is ignored when writing fixed length data
+        buffer.position(fixedDataStart + col.getFixedDataOffset());
+        buffer.put(col.write(rowValue, 0));
 
-            // keep track of the end of fixed data
-            if(buffer.position() > fixedDataEnd) {
-              fixedDataEnd = buffer.position();
-            }
-          }
-        }
       }
+
+      // always insert space for the entire fixed data column length
+      // (including null values), access expects the row to always be at least
+      // big enough to hold all fixed values
+      buffer.position(fixedDataStart + col.getFixedDataOffset() +
+                      col.getLength());
+
+      // keep track of the end of fixed data
+      if(buffer.position() > fixedDataEnd) {
+        fixedDataEnd = buffer.position();
+      }                  
+      
     }
 
     // reposition at end of fixed data