Menu

#550 ZMemTable ignoring required fields

8.0-Beta
open
nobody
None
Bug Report
2022-05-29
2022-05-29
No

This is a crosspost from the forums: https://zeoslib.sourceforge.io/viewtopic.php?f=50&t=159196

It's not an inconvenience at all but at least easy to reproduce. Have a ZMemTable, a datasource and a DBGrid connected on your blank app, and write the following code:

procedure TForm1.FormCreate(Sender: TObject);
begin
 ZMemTable1.FieldDefs.Add('ID', ftLargeInt, 0, True);
 ZMemTable1.FieldDefs.Add('Text', ftWideString, 100, True);

 ZMemTable1.Open;

 ZMemTable1.Append;
 ZMemTable1.FieldByName('ID').AsLargeInt := ZMemTable1.RecordCount + 1;
 ZMemTable1.Post;
end;

In theory, this shouldn't be possible, post should throw an exception but instead, one record is visible in the grid.

I used a ZMemTable to display a data structure in a heavily customized DBGrid, so it really doesn't matter for me. However, this should be looked at in the future. A quick debug in .Post reveals absolutely zero checks on required fields whatsoever; maybe because TZVirtualResultSet.PostRowUpdates is empty. I admit I was a bit lazy to check where the exception is raised with TZQuery.

Using D11.1 patch 1 but I suspect a check is missing in Zeos's code so it shouldn't matter.

Related

Commit: [r7893]
Commit: [r7925]
Commit: [r7939]

Discussion


Log in to post a comment.