CRUD List sort broken

Bug #515183 reported by koziolek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
play framework
Status tracked in 1.0
1.0
Fix Released
Undecided
Unassigned
1.1
Fix Committed
Undecided
Unassigned

Bug Description

Play Framework 1.0 b833

Steps to reproduce:
1. Create new application.
2. Add some Model class (my is MyModel/).
3. Activate CRUD module and configure it (my is admin/).
4. Create CRUD controller without any methods (my is mymodels).
5. Open CRUD panel for your model class and add some new objects.
6. Open admin/mymodels/ and try to sort list od objects.

List is always sort by Id DESC.

Source of problem:
in file CRUD.java lines 236-238:
if (orderBy == null) {
    orderBy = "id";
    order = "DESC";
}

If orderBy param is null in request then list is sort by Id DESC. It is wrong because controller doesn't allow to define order param and not define orderBy param.

Solution:
change lines to:
if (orderBy == null && order == null) {
    orderBy = "id";
    order = "ASC";
}

if (orderBy == null && order != null) {
    orderBy = "id";
}

First conditional provides situation when we not add orderBy and order params. In this situation controller set natural id ordering.
Second conditional provides situation when we add order but not add orderBy param. In this situation controller order by id use ordering defined in order parameter.

Tags: crud
Revision history for this message
Guillaume Bort (guillaume-bort) wrote :

I can't reproduce it. Works for me.

Revision history for this message
Guillaume Bort (guillaume-bort) wrote :

Ah ok I see the bug, sorry.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.