The problem occurs when sorting multiple columns simultaneously in the BufDataSet.
When sorting with multiple columns in BufDataSet, there can be issues.
SQLQuery1.IndexFieldNames:='c1;c2 DESC';
This should sort column c1 in ascending order and column c2 in descending order, but in reality, both columns c1 and c2 are sorted in descending order.
This issue affects controls such as SQLQuery and BufDataSet.
Testing with four combinations for two columns:
Both ascending: c1;c2
One descending: c1 DESC;c2 c1;c2 DESC
Both descending: c1 DESC;c2 DESC
As long as there is a DESC, all columns are sorted in descending order.
To fix this issue, within the bufdataset.pas file, locate the function:
procedure TCustomBufDataset.ProcessFieldsToCompareStruct
...
ACompareRec.Desc := ACompareRec.Desc or (ADescFields.IndexOf(AField)>-1);
...
By changing the or to and, the sorting will work as expected:
ACompareRec.Desc := ACompareRec.Desc and (ADescFields.IndexOf(AField)>-1);