NULL prefered in ORDER BY?

#1

Hi!

Is there a way to NOT prefer NULL in Order BY? I.e. assume this:

@Entity
class Hint
{
    private String name;
}

@Entity
class Test
{
    private Hint hint;
}

I've got a few Test entries, some do have a hint assigned, some do not (NULL). Now when I do something like

SELECT FROM Test ORDER BY hint.name

It orders ASC like this (assuming I've got three Test Entities whereas first one points to Hint{name=A}, second one to Hint{name=B} and third one to NULL:

Test 3 (with hint = NULL)
Test 1 (with hint = A )
Test 2 (with hint = B)

And descending:

Test 2 (with hint = B)
Test 1 (with hint = A)
Test 3 (with hint = NULL)

Descending looks just fine though what I want for ASC (because it simply makes more sense) is:

Test 1 (with hint = A)
Test 2 (with hint = B)
Test 3 (with hint = NULL)

Any ideas?

thanks,

Alex

#2

This is currently not supported. null values are smaller than any other value so they appear first in ordering. Please fill a feature request if you need this functionality.

As as side note, I edited your original post adding 3 styles (for code, for query and for shell output). Please use styles in your future posts. It makes posts much more readable.

ObjectDB Support

Reply