albfernandez / javadbf

Java library for reading and writing Xbase (dBase/DBF) files.
GNU Lesser General Public License v3.0
220 stars 98 forks source link

row.isDeleted() returns wrong result #99

Closed idfake closed 2 years ago

idfake commented 2 years ago

I have a dbf with a deleted row, but isDeleted() fails.

Debugging showed that this.fields[0].getName() in isDeleted() doesn't return "deleted", but the name of the first data column in the dbf. File was created with vfp8.

public boolean isDeleted() {
    return "deleted".equals(this.fields[0].getName()) && getBoolean("deleted");
}

My simple Testprg:

DBFReader reader = null;
try {
  reader = new DBFReader(new FileInputStream("D:\test.dbf"),true);
  DBFRow row;
  while ((row = reader.nextRow()) != null) {
    if ( row.getBoolean("deleted")!=row.isDeleted()) {
      System.out.println("Oops. DELETED differs");
    }
  }
} catch (DBFException e) {
  e.printStackTrace();
} catch (IOException e) {
  e.printStackTrace();
}
finally {
  DBFUtils.close(reader);
}

Output: Oops. DELETED differs

albfernandez commented 2 years ago

Fixed, thanks for the detailed test.