TZQuery.Locate method loPartialKey is ignored

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
martinus
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 02.12.2024, 15:49
Contact:

TZQuery.Locate method loPartialKey is ignored

Post by martinus »

Hi

I found that the TZQuery.Locate method with loPartialKey doesn't work anymore as expected on Zeos 8.0
At least using Ubuntu 24.04, Lazarus 3.6, and MariaDb Ver 15.1 Distrib 10.11.8-MariaDB, for debian-linux-gnu (x86_64)

Problem is :
When the first characters of an existing key are entered, the result of Locate returns false (and the position in the Dataset don't change).
When a full existing key is entered, the Locate returns true and position is changed, as expected.
Looks like [loPartialKey] is ignored.

I have checked that it is OK with Zeos 7.2.6 and the same code and configuration.

I can easily reproduce with an example project, containing :

Code: Select all

procedure TForm1.Edit1Change(Sender: TObject);
begin
  if ZreadonlyQuery1.Locate ('Account', edit1.Text, [loPartialKey] ) then
    caption := 'found'
  else
    caption := 'not found';
end;   
For the example need to create a table with at least one field "Account" VARCHAR (10) and populate it.
Or you can adapt the code to an existing table.
I'm unable to add the example project in attachments.
martinus
Fresh Boarder
Fresh Boarder
Posts: 6
Joined: 02.12.2024, 15:49
Contact:

Re: TZQuery.Locate method loPartialKey is ignored

Post by martinus »

Hi

I have found where is the bug.

In src/components/ZDatasetUtils.pas, line 1138 should be :

Code: Select all

WValue2 := Copy(WValue2, 1, L1);  
instead of

Code: Select all

WValue2 := Copy(WValue2, 1, L2);
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 2001
Joined: 17.01.2011, 14:17

Re: TZQuery.Locate method loPartialKey is ignored

Post by marsupilami »

Hello martinus,

I added your patch to the SVN. Thank you :)

Best regards,

Jan
Post Reply