TAureliusDataset: inserted record lost when dataset layout changed

If I have a TAureliusDataset instance using a source list and, after opening the dataset, I do something to change the dataset's layout (e.g. - change field indexes) before calling Insert, subsequently attempting to read any field's value before calling Post causes the inserted record to "vanish" and any field values that may have been previously set are seemingly lost. Calling Post after this results in an access violation exception.

Below is some simple code to demonstrate. Assume that TMyEntity has two or more properties and one of them is a string called MyField.

var ds := TAureliusDataset.Create(nil);
var list := TList<TMyEntity>.Create;
ds.SetSourceList(list);
ds.Open;
ds.Fields[0].Index := (ds.Fields.Count - 1);
ds.Insert;
ds.FieldByName('MyField').AsString := 'A';
var myFieldVal := ds.FieldByName('MyField').AsString;	// myFieldVal should end up 'A' but instead is '' (empty string)
ds.Post;	// AV occurs here

Hello @sferris,

Sorry, I couldn't reproduce the issue. Here is a sample project.

TestFieldIndex.zip (6.5 KB)

Thanks for having a look, Wagner!
Using your sample project: if you disable DataSource1 in the designer before running, myFieldVal will incorrectly end up as 'Ronaldo' but there's no AV. If you don't put any items into List before opening the dataset, myFieldVal ends up as '' and you'll get the AV on Post.

Thanks for more detailed explanation. We could reproduce it here. Fix will be included in next release.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.