Menu

#82 IsNull does not work

Win32/Linux
open
nobody
None
5
2016-02-04
2016-02-04
Karel Rys
No

When there is a FNullField, .IsNull does not return corect values. Even when I call .Clear on a field, call to .IsNull returns false. In think there is an error in function TDbfFile.GetFieldData(Column: Integer; DataType: TFieldType; Src, Dst: Pointer; NativeFormat: boolean): Boolean;
It should return false, when the field is Null. Correct check for null should probably be:

// check Dst = nil, called with dst = nil to check empty field
if (FNullField <> nil) and (Dst = nil) and (AFieldDef.NullPosition >= 0) then
begin
// go to byte with null flag of this field
Src := PAnsiChar(Src) + FNullField.Offset + (AFieldDef.NullPosition shr 3);
Result := ((PByte(Src)^ and (1 shl (AFieldDef.NullPosition and $7))) = 0);
exit;
end;

Discussion


Log in to post a comment.