History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: COR-1007
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Adriano Verona
Reporter: Glaz Glazz@mail.ru
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
db4o Core

Sorting SODA Query , order by Asceding seems as Descending

Created: 23/Nov/07 05:32 AM   Updated: 13/Dec/07 03:16 AM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Original Estimate: Not Specified
Remaining Estimate: 0h
Time Spent - 19.02h
Time Spent: 19.02h
Time Spent - 19.02h

Peers: Richard Liang
Order: 3
Iteration: 21
Original IDS Estimate: 2.0 IDD (time boxed)
Resolution Date: 12/Dec/07 03:41 AM
First Response Date: 05/Dec/07 11:49 AM
Labels:
Participants: Adriano Verona and Glaz Glazz@mail.ru
Number of Attachments: 0
Number of Comments: 2


 Description  « Hide
package Glaz.Test2;

import java.io.File;
import com.db4o.*;
import com.db4o.query.Query;


public class Test2 {

    public static final String db_file="test.db4o";
   
    public static void main(String[] args) {
        ObjectContainer db=null;
        ObjectServer server=null;
       try{
       File file=new File(db_file);
       file.delete();
       server=Db4o.openServer(db_file,1080);
       server.grantAccess("SA","");
       db=Db4o.openClient("127.0.0.1",1080,"SA" ,"");
       runTest(db);
      
          
       }catch(Exception e){e.printStackTrace();}finally{
           if(db!=null)
            db.close();
           if(server!=null)
           server.close();
       }
    }
   
    public static void runTest(ObjectContainer db)throws Exception{
       
           Pilot pilot=null;
          
          
           pilot=new Pilot("Alexandr",30,5);
           db.set(pilot);
           
           pilot=new Pilot("Cris",30,5);
           db.set(pilot);
          
           pilot=new Pilot("Boris",30,5);
           db.set(pilot);

          
           pilot=new Pilot("Helen",25,5);
           db.set(pilot);

           pilot=new Pilot("Zeus",25,3);
           db.set(pilot);
          
           pilot=new Pilot("Alexsandra",25,3);
           db.set(pilot);
           
           pilot=new Pilot("Liza",25,4);
           db.set(pilot);
          
           pilot=new Pilot("Bred",25,4);
           db.set(pilot);
          
           pilot=new Pilot("Gregory",25,4);
           db.set(pilot);
                      
           db.commit();
          
           Query query=db.query();
           query.constrain(Pilot.class);
           query.descend("seniority").orderAscending();
           query.descend("age").orderAscending();
           query.descend("name").orderAscending();
                     
           ObjectSet result=query.execute();
           System.out.println("seniority age name");
               while(result.hasNext()){
                pilot=(Pilot)result.next();
                System.out.println(pilot.seniority+" "+pilot.age+" "+pilot.name);
             }
       
    }
}

//****************************************************************************************************

package Glaz.Test2;

public class Pilot {
 public String name;
 public int seniority;
 public int age;
 public Pilot(String name,int age, int seniority){
  this.name=name;
  this.age=age;
  this.seniority=seniority;
 }

   
}
//**********************************************************************************************

System.out:

seniority age name
3 25 Zeus
3 25 Alexsandra
4 25 Liza
4 25 Gregory
4 25 Bred
5 25 Helen
5 30 Cris
5 30 Boris
5 30 Alexandr

//********************************************************************

 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Adriano Verona - 05/Dec/07 11:49 AM
- The problem happens in the latest version (7.0.x) in both platforms (Java and .Net)

- The problem seems to be triggered when sorting by multiple fields and the last field is used to resolve the sort order. For example:

         0 1 2
         ----------
         A A 2
         B B 1
         A A 1

    If we try to sort by fields 0, 1 and 2 (in this order) we should get:

       A A 1
       A A 2
       B B 1

   but instead we get (the results are sorted in descendant instead of ascendant order):

       A A 2
       A A 1
       B B 1

    If we do not sort by field 1 then result is correct.

Adriano Verona - 05/Dec/07 12:16 PM
It seems that this issue was introduced in Db4o 6.1 as it doesn't shows up in Db4o 6.0 (.Net version at least) but it DOES shows up in 6.1.