Details
-
Type:
Sub-task
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 0.3.1
-
Fix Version/s: 1.1-beta1
-
Component/s: Persistence
-
Labels:None
Description
I would be nice if you could specify a default sort and order for domain classes, like:
class NewsArticle
{ static defaultSort = 'publishedAt' static defaultOrder = 'desc' String title Date publishedAt .... }Issue Links
- is duplicated by
-
GRAILS-3038
Add support for ordering an object's collections at the SQL / DB level
-
This is an excellent idea Paul. I was just about to submit an issue and saw that you did for me. I have a large domain model and I find it annoying to have to always mention what I want to sort something by. I'd like to be able to declare in my model what the default is, and then I'll get automatic sorting with the list and findAllBy* methods without having to further specify things. Most if not all times you query for a list of things, you're going to show it to the user so I hold the opinion that you should get a consistent order in the default case (without having to specify anything). I think the id (which would amount to the insertion order) should be the default. This means you'll always get a sort.