Lazarus - TZUpdateSQL not bringing its update fields selected

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
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

Hello friends, I have notice that on Lazarus 2.2.4 or above, on the TzUpdateSQL component, the existing update fields are not been selectec when we double click the component. Please see attachment. I wonder if this is a new behavior or a simple bug. On my earlier lazarus version all fields were selected automatically as we defined the last time we edited the component.

Image

Note: Also tested with Zeoslib 8.x. Same behavior.

Thanks.
Renato Ricci
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by marsupilami »

Hello Renato,

currently this is a known issue that I cannot fix. There are other bugs that have to be fixed first.

With best regards,

Jan
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

marsupilami wrote: 11.05.2023, 08:41 Hello Renato,

currently this is a known issue that I cannot fix. There are other bugs that have to be fixed first.

With best regards,

Jan
Hello Jan.. Thanks for the feedback.. For now I will keep with the previous version..

Thanks and good luck!
Renato
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

Hi friends.. any news about this bug? Is there any patch?

Thanks

Renato
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by marsupilami »

Hello Renato,

unfortunately - no. There simply was no time to look at it yet.

With best regards,

Jan
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

marsupilami wrote: 26.07.2023, 07:41 Hello Renato,

unfortunately - no. There simply was no time to look at it yet.

With best regards,

Jan
If you would like to, you can give me some tips where to look around in the code and I'll try to fix it, and then I'll post you back the solution.

PS: Using Lazarus 2.2.6 / FPC 3.2.2

Thanks.
Renato
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by marsupilami »

Hello Renato,

I think the starting point for thius would be ZUpdateSqlEditor.pas in src\component. I assume, it contains the editor window for TZUpdateSQL. I didn't work on that code (yet) so I don't know what it looks like in there.

Best regards,

Jan
User avatar
singlesis
Fresh Boarder
Fresh Boarder
Posts: 1
Joined: 12.01.2024, 18:41

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by singlesis »

Same problem here utilizing Lazarus 3.0.. is there any patch to correct it? Tks.
marsupilami
Platinum Boarder
Platinum Boarder
Posts: 1956
Joined: 17.01.2011, 14:17

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by marsupilami »

Hello singlesis,

unfortunately there is no patch yet.

With best regards,

Jan
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

Hello.. I think I found the solution.. Please validade it..

At file ZUpdateSqlEditor.pas in src/component I have commented out the 2 lines below and it worked, cause does not make sense the component set selected(i) = true and later on it set the itemindex equals 0. (will loose the selection right?). Please check if this is the correct berravior, since as I said, I am not so experient on the component.

1. ListBox.ItemIndex := 0;
2. ListBox.TopIndex := 0;

Code: Select all

function SetSelectedItems(ListBox: TListBox; List: TStrings): Integer;
var
  I: Integer;
begin
  Result := 0;
  ListBox.Items.BeginUpdate;
  try
    for I := 0 to ListBox.Items.Count - 1 do
      if List.IndexOf(ListBox.Items[I]) > -1 then
      begin
        ListBox.Selected[I] := True;
        Inc(Result);
      end
      else
        ListBox.Selected[I] := False;
    if ListBox.Items.Count > 0 then
    begin
      //ListBox.ItemIndex := 0;
      //ListBox.TopIndex := 0;
    end;
  finally
    ListBox.Items.EndUpdate;
  end;
end;
Also commented the 2 lines at 'SelectAll' procedure:, witch is related to the popup menu..

Code: Select all

procedure SelectAll(ListBox: TListBox);
var
  I: Integer;
begin
  ListBox.Items.BeginUpdate;
  try
    with ListBox do
      for I := 0 to Items.Count - 1 do
        Selected[I] := True;
    if ListBox.Items.Count > 0 then
    begin
      //ListBox.ItemIndex := 0;
      //ListBox.TopIndex := 0;
    end;
  finally
    ListBox.Items.EndUpdate;
  end;
end; 

Thanks.
Renato
Last edited by rrricci on 06.09.2024, 15:14, edited 2 times in total.
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

Just a correction.. Also comment the block:

if ListBox.Items.Count > 0 then
begin
end;

Thanks
Renato Ricci
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 797
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by aehimself »

To be honest it's a little bit confusing for me as well. Individual items are (de)selected within the cycle and then we are moving the selection back to the first one? TopIndex alone would make sense IF it does not change selection.

Also what I can not understand, why we are selecting all items in ListBox by hand, if I'm 99% sure ListBox has a .SelectAll method...?
I'll fire up a Delphi 7 to confirm these.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 797
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by aehimself »

I did a minimal example and I can confirm that

1, Under Delphi 7 TListBox has .Selected[], .TopIndex and .SelectAll methods
2, Setting .Selected[] or invoking .SelectAll indeed moves the node in question to be visible (they do scroll the scrollbox)

So, the below code is the most efficient and fool-proof way I can imagine:

Code: Select all

procedure TForm1.SelectRandomButtonClick(Sender: TObject);
Var
  a: integer;
begin
  ListBox1.Items.BeginUpdate;
  Try
    For a := 0 To ListBox1.Items.Count - 1 Do
      ListBox1.Selected[a] := a Mod 2 = 0;

    ListBox1.TopIndex := 0;
  Finally

    ListBox1.Items.EndUpdate;
  End;
end;

procedure TForm1.SelectAllButonClick(Sender: TObject);
begin
  ListBox1.Items.BeginUpdate;
  Try
    ListBox1.SelectAll;

    ListBox1.TopIndex := 0;
  Finally
    ListBox1.Items.EndUpdate;
  End;
end;
Screenshot_20240908_153626.png
You do not have the required permissions to view the files attached to this post.
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
User avatar
aehimself
Zeos Dev Team
Zeos Dev Team
Posts: 797
Joined: 18.11.2018, 17:37
Location: Hungary

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by aehimself »

Since it is 100% Delphi 7 compatible I issued a pull request on GitHub. I don't have any real-world application to test it on though so I'll leave that to the community :)
Delphi 12.2, Zeos 8 from latest GIT snapshot
Using:
- MySQL server 8.0.18; libmysql.dll 8.0.40 x64 5.7.19 x68, libmariadb.dll 3.3.11
- Oracle server 11.2.0, 12.1.0, 19.0.0; oci.dll 21.15
- MSSQL 2012, 2019; sybdb.dll FreeTDS_3102
- SQLite 3.47
rrricci
Fresh Boarder
Fresh Boarder
Posts: 14
Joined: 05.04.2014, 02:12

Re: Lazarus - TZUpdateSQL not bringing its update fields selected

Post by rrricci »

Great!

Thanks aehimself!
Post Reply