INSERT into an empty dataset fails to set BOF to false
Original Reporter info from Mantis: TWhyman
-
Reporter name: Tony Whyman
Original Reporter info from Mantis: TWhyman
- Reporter name: Tony Whyman
Description:
The TDataset.Append method may be used to insert a record into an empty database or to add a record to a non-empty database. It should similarly be possible to use the TDataset.Insert method to add a record to an empty database. However, this is not possible as there appears to be a bug in the internal TDataset.DoInsertAppend method which, while setting FBof to false when called via TDataset.Append, leaves it set to true when called via TDataset.Insert. As a result TDataset.IsEmpty always returns true and it is impossible to read from the dataset. Field data is thus always null.
TDataset.Append can always used as a workaround for a bidirectional database. However, this is not possible for a unidirectional dataset as a call to TDataset.Append always results in an exception reporting that the action is not permitted for a unidirectional dataset.
Steps to reproduce:
This problem is easily demonstrated with any editable TDataset descendent after an empty dataset is opened. First invoke:
Append;
writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);
This should show BOF = false, EOF = true. Then invoke
Insert;
writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);
This returns BOF=true, EOF = true.
Additional information:
The fix is probably as simple as adding FBof := false to the DoInsertAppend method. I.e.
If Not DoAppend then
begin
{$ifdef dsdebug}
Writeln ('going to insert mode');
{$endif}
DoInsert(false);
FBof := false; //Proposed bug fix
end
else
begin
...
Mantis conversion info:
- Mantis ID: 37900
- OS: Linux
- OS Build: Mint 19.3
- Platform: x86_64
- Version: 3.0.4