View Issue Details

IDProjectCategoryView StatusLast Update
0037900FPCDatabasepublic2020-10-12 10:46
ReporterTony Whyman Assigned To 
Status newResolutionopen 
Product Version3.0.4 
Summary0037900: INSERT into an empty dataset fails to set BOF to false
DescriptionThe 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 ReproduceThis problem is easily demonstrated with any editable TDataset descendent after an empty dataset is opened. First invoke:

      writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);

This should show BOF = false, EOF = true. Then invoke

      writeln(outfile,'BOF = ',BOF,', EOF = ',EOF);

This returns BOF=true, EOF = true.

Additional InformationThe fix is probably as simple as adding FBof := false to the DoInsertAppend method. I.e.

  If Not DoAppend then
{$ifdef dsdebug}
    Writeln ('going to insert mode');
   FBof := false; //Proposed bug fix
TagsNo tags attached.
Fixed in Revision
Attached Files



2020-10-12 10:46

developer   ~0126252

I did test in Delphi 7 with TClientDataSet and after Insert there are both BOF and EOF = True.
There is also test TTestCursorDBBasics.TestInsertOnEmptyDataset for this situation.
So it seems that it is expected behaviour.

Issue History

Date Modified Username Field Change
2020-10-09 14:46 Tony Whyman New Issue
2020-10-12 10:46 LacaK Note Added: 0126252