View Issue Details

IDProjectCategoryView StatusLast Update
0038884FPCDatabasepublic2021-05-13 16:14
Reporterjciberta Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
Product Version3.2.0 
Summary0038884: Problems sorting a DataSet
DescriptionThe 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 ReproduceA sample program is attached.
Additional InformationI'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
TagsNo tags attached.
Fixed in Revision
FPCOldBugId
FPCTarget
Attached Files

Activities

jciberta

2021-05-13 11:52

reporter  

TEST.zip (471,000 bytes)

jciberta

2021-05-13 11:54

reporter   ~0130852

Last edited: 2021-05-13 16:14

View 2 revisions

Sorry, I didn't choose the project properly. It's my first time using this software

jciberta

2021-05-13 16:14

reporter   ~0130855

Additional information

Lutz Mändle posted a message that maybe helps the mantainer
https://forum.lazarus.freepascal.org/index.php/topic,54582.msg405646.html#msg405646

Issue History

Date Modified Username Field Change
2021-05-13 11:52 jciberta New Issue
2021-05-13 11:52 jciberta File Added: TEST.zip
2021-05-13 11:54 jciberta Note Added: 0130852
2021-05-13 16:14 jciberta Note Added: 0130855
2021-05-13 16:14 jciberta Note Edited: 0130852 View Revisions