Menu

#120 ColumnBuilder validate warning using .setFromColumn() with Yes/No field

2.0.9
closed
nobody
None
1
2015-03-19
2015-03-12
No

I was curious to see if the recent changes for 2.0.9 re:

https://sourceforge.net/p/jackcess/bugs/116/

happened to fix the warning messages generated by Yes/No fields when copying a table using the sample code in

https://sourceforge.net/p/jackcess/discussion/456474/thread/1822053e/#9857/0f32

Apparently not. For a table named [TableA]

ID - AutoNumber, Primary Key
TextField - Text(255)
YesNoField - Yes/No

the following code using jackcess-2.0.9-SNAPSHOT.jar (Revision 919) does successfully copy the table ...

String dbFile = "C:/Users/Public/test/jackcessTest.accdb";
String dbFileNew = "C:/Users/Public/test/zzzTest.mdb";

File dbA_File = new File(dbFile);
File dbB_File = new File(dbFileNew);
try (Database dbA = DatabaseBuilder.open(dbA_File)) {
    String tableName = "TableA";  // for example
    Table tableA = dbA.getTable(tableName);

    Database dbB;
    if (dbB_File.exists()) {
        dbB = DatabaseBuilder.open(dbB_File);
    } else {
        dbB = DatabaseBuilder.create(Database.FileFormat.V2003, dbB_File);
    }
    // create the target table ...
    TableBuilder tb = new TableBuilder(tableName);
    for (Column col : tableA.getColumns()) {
        tb.addColumn(new ColumnBuilder(col.getName()).setFromColumn(col));
    }
    Table tableB = tb.toTable(dbB);
    // ... and copy the rows from the source table
    for (Row rowA : tableA) {
        tableB.addRowFromMap(rowA);
    }
    dbB.close();
} catch (Exception e) {
    e.printStackTrace(System.err);
}

... but it also generates the warning

Mar 12, 2015 1:24:58 PM com.healthmarketscience.jackcess.ColumnBuilder validate
WARNING: Column length 1 longer than expected fixed size 0(Column=YesNoField)

Discussion

  • James Ahlborn

    James Ahlborn - 2015-03-19

    removed the warning since it wasn't really all that useful.

    fixed in trunk, will be in the 2.0.9 release.

     
  • James Ahlborn

    James Ahlborn - 2015-03-19
    • status: open --> closed
    • Group: Unassigned --> 2.0.9
     

Log in to post a comment.

MongoDB Logo MongoDB