ZMemTable ignoring required fields

The offical for ZeosLib 7.3 Report problems, ask for help, post proposals for the new version of Zeoslib 7.3/v8
Quick Info:
-We made two new drivers: odbc(raw and unicode version) and oledb
-GUID domain/field-defined support for FB
-extended error infos of Firebird
-performance ups are still in queue
In future some more feature will arrive, so stay tuned and don't hassitate to help
Post Reply
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

ZMemTable ignoring required fields

Post by aehimself »

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:

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;
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.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: ZMemTable ignoring required fields

Post by marsupilami »

Hello aehimself,

I created a bug report for this on the bug tracker: https://sourceforge.net/p/zeoslib/tickets/550/

Currently I am out of time becaus emy job requires all my free time. This bug report makes sure, it is not forgotten.

Best regards,

Jan
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: ZMemTable ignoring required fields

Post by aehimself »

Fixed :)

Pull request available on GitHub.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: ZMemTable ignoring required fields

Post by aehimself »

Does anyone know what this means by the way? This is why inherited isn't called, this is why required fields are simply ignored.

//AVZ - Firebird defaults come through when this is commented out

Maybe it worth a try to simply call inherited and run it against the tests. I would like that solution better than the overridden method - but again, only if it's not causing issues with FireBird.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1939
Joined: 17.01.2011, 14:17

Re: ZMemTable ignoring required fields

Post by marsupilami »

aehimself wrote: 26.10.2022, 11:44 Does anyone know what this means by the way? This is why inherited isn't called, this is why required fields are simply ignored.

//AVZ - Firebird defaults come through when this is commented out

Maybe it worth a try to simply call inherited and run it against the tests. I would like that solution better than the overridden method - but again, only if it's not causing issues with FireBird.
We will do exactly that. I will fire up the test server today after lunch. Then I will make the necessary changes in Zeos 8.0. If these changes fix the problem, we probably transfer that solution to trunk.

Thank you for your work :)
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: ZMemTable ignoring required fields

Post by aehimself »

I saw that Michael took a different approach fixing this, the commit is already in SubVersion. However I don't see the reason for a required check to be implemented 3 different locations (once in TDataSet, once in TZAbstractRODataset and now in TZMemTableResultSet) this solution feels a lot more elegant than mine :)

Just make sure that these won't interfere with each other.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
hemmingway
Fresh Boarder
Fresh Boarder
Posts: 21
Joined: 20.01.2010, 13:51

Re: ZMemTable ignoring required fields

Post by hemmingway »

Hello,

now I must disable required check on one table (TZTable).
The required fields on a MariaDB server are filled, but the check raises an exception.

Greeings, Bernhard
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 787
Joined: 18.11.2018, 17:37
Location: Hungary

Re: ZMemTable ignoring required fields

Post by aehimself »

Can you check the metadata, if NULLABLE is properly returned and detected by Zeos?
Also, a minimal example would be appreciated so we can check what is going wrong.
Delphi 12.1, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmariadb.dll 3.3.8
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.13
- MSSQL 2012, 2019; sybdb.dll FreeTDS_2435
- SQLite 3.45.2
Post Reply