Recent

Author Topic: ZDataset.Locate + loPartialKey  (Read 2131 times)

tintinux

  • Sr. Member
  • ****
  • Posts: 351
    • Gestinux
ZDataset.Locate + loPartialKey
« on: December 02, 2024, 04:47:48 pm »
Hi

With Zeos 8.0, I found that the TZQuery.Locate method with loPartialKey doesn't work anymore as usual.
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)

Unfortunately, I can't post on the ZeosLib forum (blocked, unable to access sourceforge.io) and don't find a related post elsewhere.
But I don't know if the issue is related to ZeosLib or Lazarus...

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'm sure that it was ok with Zeos 7 and the same code and configuration.

I can easily reproduce with this code example (only one string field).

Code: [Select]
procedure TForm1.Edit1Change(Sender: TObject);
begin
  if ZreadonlyQuery1.Locate ('Account', edit1.Text, [loPartialKey] ) then
    caption := 'found'
  else
    caption := 'not found';
end;   

I have attached the full Lazarus project.
Enter the name, username and password of your database in Zconnection1, and
Code: [Select]
CREATE TABLE Accounts ( Account VARCHAR(10) NOT NULL );
INSERT INTO Accounts VALUES ('1000'), ('1005'), ('2000');
Or you can adapt the code to an existing table...

Any ideas or workaround ?
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

tintinux

  • Sr. Member
  • ****
  • Posts: 351
    • Gestinux
Re: ZDataset.Locate + loPartialKey
« Reply #1 on: December 03, 2024, 03:19:10 pm »
The problem seems new with ZeosLib 8.0

I have installed ZeosLib 7.2.6 and it works fine as expected with the example.
Some manual changes are required in the .lfm, I find no way to make it compatible with both versions. :(

Unfortunately there are other bugs in this version, solved only by the 8.0.
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

Sieben

  • Sr. Member
  • ****
  • Posts: 372
Re: ZDataset.Locate + loPartialKey
« Reply #2 on: December 03, 2024, 11:30:03 pm »
Why not use SQLdb then?
Lazarus 2.2.0, FPC 3.2.2, .deb install on Ubuntu Xenial 32 / Gtk2 / Unity7

tintinux

  • Sr. Member
  • ****
  • Posts: 351
    • Gestinux
Re: ZDataset.Locate + loPartialKey
« Reply #3 on: December 04, 2024, 09:14:48 am »
You are off topic, but the answers to your question are :
1) SqlDb can attach to only one Database type (and sometimes to only one Database version) at a time.
2) SqlDb doesn't exist for Delphi AFAIK, and many developers are required to use it and don't want to have to master too many packages
3) I would have all my projects to change and test, with no known advantage.
4) I am sure that a workaround or a fix will be find to solve my small issue
Regards
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

silvercoder70

  • Full Member
  • ***
  • Posts: 118
    • Tim Coates
Re: ZDataset.Locate + loPartialKey
« Reply #4 on: December 10, 2024, 10:49:08 am »
I typically use Filter/Filtered properties of the query with LIKE

Not sure how well that would work in your scenario?

if Edit1.Text = '' then Query1.Filtered := False else begin
Query1.Filter := ...; Query1.Filtered := True;
end;
Explore the beauty of modern Pascal programming with Delphi & Free Pascal - https://www.youtube.com/@silvercoder70

tintinux

  • Sr. Member
  • ****
  • Posts: 351
    • Gestinux
Re: ZDataset.Locate + loPartialKey
« Reply #5 on: December 17, 2024, 11:51:50 am »
Hi

The bug is fixed in the SVN of ZeosLib.

More details here.

Cheers
Initiator of gestinux, open-source, multi-database and multilingual accounting and billing software made with LAZARUS.

You can help to develop, to make and improve translations, and to provide examples of legal charts and reports from more countries.

 

TinyPortal © 2005-2018