[bug_fixed] Do not work sorterfields

In this forum all bug reports concerning the 6.x branch will be gahtered. You have the possibility to track the bug fix process.

Moderators: EgonHugeist, mdaems

Visor123
Fresh Boarder
Fresh Boarder
Posts: 22
Joined: 07.09.2005, 10:20
Location: Dnepr

[bug_fixed] Do not work sorterfields

Postby Visor123 » 21.11.2006, 14:46

In previor 6.5 version sorting in dataset (class TZAbstractRODataset) work absolutately correct.

In version 6.6 bangfauzan modifation have broken sorting.

Where sort asc or desc in 1 field, method do not work.
Example
Sord ID asc, Name desc this method do not work correct.

method InternalSort
if FIndexFieldNames = '' then exit; {bangfauzan addition}

Why if dataset do not have index - do not sort?

Please rework this methods.

bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Postby bangfauzan » 22.11.2006, 03:58

Currently, sorting two or more fields with different sort method (asc on one field and desc on the others) doesnt work. becouse order method handled by SortType property which we can sort asc only or desc only over all of fields defined in SortedFields.

obviously, it is a bug. and I will try to rework it.

for this moment, you can use sql script.

regards.

bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Bug-Fix for SortedFields, SortType and IndexFieldNames

Postby bangfauzan » 23.11.2006, 02:35

Before this revision, SortType has only 2 values (stAscending and stDescending). So, consistent with that, all field on the SortedFields can be sorted ascending only or descending only.
Now, I add new value into SortType named stIgnored, means that SortType being Ignored and we can sort each field iether ascending or descending separately.

So, we can type : "ID Asc;Name Desc" on the SortedFields or IndexFieldNames, and i works properly with correct results.

The revision attached below.

Regards.
You do not have the required permissions to view the files attached to this post.

User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Postby cipto_kh » 23.11.2006, 03:48

yes, I think it's the best solution, it can make Zeos more powerful for sorting. I agree with your solution bangfauzan, and I hope it will be included in the stable release of ZeosDBO

bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Re: [bug_report] Do not work sorterfields

Postby bangfauzan » 23.11.2006, 05:15

Visor123 wrote:
method InternalSort
if FIndexFieldNames = '' then exit; {bangfauzan addition}

Why if dataset do not have index - do not sort?



Correction :
In the current version 6.6.0 beta, IndexFieldNames does not relate to the Index, but for sorting only. Becouse the old IndexFieldNames (as you mean) was replaced by LinkedFields.

Regards.

pawelsel
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 13.11.2006, 09:39
Location: Olsztyn

Postby pawelsel » 23.11.2006, 10:37

Check my post http://zeos.firmos.at/viewtopic.php?t=898.

bangfauzan, Your new solution doesn't work with many fields.

Firstly.

In SetSortedFields You first get sort type, than You cut text after first space.
It doesn't occure when there are simultaneously ASC and DESC in Value or
if there are not ASC and DESC and previous value of FSortType was stIgnored (by default is stAscending).

If you have to remove ASC and DESC from Value,
instead of:

Code: Select all

    if (FSortType <> stIgnored) and (Pos(' ',Value)>0) then
       Value:=Copy(Value,1,Pos(' ',Value)-1); {bangfauzan addition}


try this:

Code: Select all

    if (FSortType <> stIgnored) and (Pos(' ',Value)>0) then
    begin
      while Pos(' DESC',UpperCase(Value))>0 do
        Value:=Copy(Value,1,Pos(' DESC',UpperCase(Value)))+
               Copy(Value,Pos(' DESC',UpperCase(Value))+6,Length(Value));
      while Pos(' ASC',UpperCase(Value))>0 do
        Value:=Copy(Value,1,Pos(' ASC',UpperCase(Value)))+
               Copy(Value,Pos(' ASC',UpperCase(Value))+5,Length(Value));
    end;


After patch over, You can check below:

Secondly.

Try to set SortFields with this:
OP_DATE DESC,OP_NR,OP_RECORD DESC

GetSortType returns stDescending!!! Why???
OP_NR is ascending by default!!!
You must use other method to determine sort type.
You must check each column in text separately.

Thirdly.

GetIndexFieldNames returns wrong value. For example:

SortedFields:='OP_DATE DESC,OP_NR DESC,OP_RECORD DESC';
GetSortType returns stDescending - correct, but
GetIndexFieldNames returns 'OP_DATE,OP_NR,OP_RECORD Desc' - INCORRECT!!! Only the third column is sorted descending, first two
column are sorted ascending.
You must set sort type of each column separately.

Please rework this methods.

Regards.

bangfauzan
Senior Boarder
Senior Boarder
Posts: 50
Joined: 31.08.2006, 10:41
Contact:

Problem Solved

Postby bangfauzan » 24.11.2006, 03:35

Hi pawelsel,
All problem so far was revised and completely solved.

Revision only made in GetSortType procedure.

Previously :

if (Pos(' ASC',UpperCase(FIndexFieldNames))>0) and
(Pos(' DESC',UpperCase(FIndexFieldNames))>0) then
Result:=stIgnored
else if Pos(' ASC',UpperCase(FIndexFieldNames))>0 then
Result:=stAscending
else if Pos(' DESC',UpperCase(FIndexFieldNames))>0 then
Result:=stDescending
else
Result:=FSortType;


Revision :

if (Pos(',',FIndexFieldNames)>0) or (Pos(';',FIndexFieldNames)>0) then
Result:=stIgnored
else if Pos(' DESC',UpperCase(FIndexFieldNames))>0 then
Result:=stDescending
else
Result:=stAscending;


In the future, if some problem found, we can share
and discuss to find solution.
Please install and test this patch,
I'm waiting for your comments.

The attachment below.

Regards.
You do not have the required permissions to view the files attached to this post.

User avatar
cipto_kh
Senior Boarder
Senior Boarder
Posts: 83
Joined: 28.09.2005, 11:22
Location: Indonesia
Contact:

Re: Problem Solved

Postby cipto_kh » 24.11.2006, 09:10

What about deleting the "SortType" property coz for me it cause more sorting problem, just put the "SortedFields" property and the documentation of the ZeosDBO add the information about how to sort it ascending or descending and how to sort multiple fields.

One question again, "IndexFieldNames" behave like "SortedFields", it will confusing for the new ZeosDBO users, I think the "IndexFieldNames" property should be deleted or not published.

Or there is any reason?

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 24.11.2006, 11:23

Hi,

If somebody confirms this last patch fixes all problems mentioned in this topic I can commit this file and close the topic.
I'll start the test suite on this version already.

Mark

pawelsel
Fresh Boarder
Fresh Boarder
Posts: 7
Joined: 13.11.2006, 09:39
Location: Olsztyn

Postby pawelsel » 24.11.2006, 12:33

Hi Mark,

Wait for results of our discussion with bangfauzan.
I think the problems from this topic are not resolved yet.

Paweł

Visor123
Fresh Boarder
Fresh Boarder
Posts: 22
Joined: 07.09.2005, 10:20
Location: Dnepr

Postby Visor123 » 24.11.2006, 13:41

Hi.

Thank. It it work.

Regards.

User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Postby mdaems » 24.11.2006, 13:51

Hi Visor,

I'll commit this version. That way this issue will be fixed in next release.

@pawelsel/@bangfauzan/@cipto_kh : if an other bug remains or you want to finetune this behaviour (which we really appreciate), please open a separate thread in the appropriate forum.(bugreport/user patch/general 6.6/...)

Mark


Return to “Bug Reports”

Who is online

Users browsing this forum: No registered users and 1 guest