ZMemTable ignoring required fields
Posted: 27.05.2022, 21:39
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:
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.
Code: Select all
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;
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.