Problems sorting a DataSet
Original Reporter info from Mantis: jciberta
-
Reporter name: jciberta
Original Reporter info from Mantis: jciberta
- Reporter name: jciberta
Description:
The folowing is not working properly when ordering a DataSet:
//SQLQuery1.IndexFieldNames:='Title DESC'; // Works fine!
//SQLQuery1.IndexFieldNames:='Title; LastName'; // Works fine!
SQLQuery1.IndexFieldNames:='Title; LastName DESC'; // WRONG: Order Title by DESC!
I just find out if you set the value of IndexFieldNames twice, it works.
//SQLQuery1.IndexFieldNames:='Title DESC'; // Works fine!
//SQLQuery1.IndexFieldNames:='Title; LastName'; // Works fine!
SQLQuery1.IndexFieldNames:='Title; LastName DESC'; // WRONG: Order Title by DESC!
SQLQuery1.IndexFieldNames:='Title; LastName DESC'; // Do it twice -> Works properly!
I tried to debug unit BufDataset, but I don't know how to do it. My guess is something is not right in function SetIndexFieldNames and BuildCustomIndex is not called the first time
Code: Pascal [Select]
[+]
procedure TCustomBufDataset.SetIndexFieldNames(const AValue: String);
begin
FIndexFieldNames:=AValue;
if (AValue='') then
begin
FCurrentIndexDef:=FIndexes.FindIndex(SDefaultIndex);
Exit;
end;
if Active then
BuildCustomIndex;
end;
Steps to reproduce:
A sample program is attached.
Additional information:
I'm using Ubuntu 18.04 with Lazarus 2.0.12 (the newest at this moment). The database engine is SQLite with Chinook database (https://github.com/lerocha/chinook-database).
I tried as well on a Windows 10, Lazarus 2.0.10. The same behaviour
Mantis conversion info:
- Mantis ID: 38884
- Version: 3.2.0