line / kotlin-jdsl

Kotlin library that makes it easy to build and execute queries without generated metamodel
https://kotlin-jdsl.gitbook.io/docs/
Apache License 2.0
653 stars 85 forks source link

Support of Sort.NullHandling from Spring #732

Open mikoaj-pe opened 1 week ago

mikoaj-pe commented 1 week ago

Hi I don't know if you are aware of this, but the findPage(pageable: Pageable) method does not fully cope with Sort from Spring. It manages to pass the direction and parameter name to the query, but loses information about NullHandling somewhere (NULLS_LAST etc.). So when I build Pageable with Sort looking like Sort.by(Order(DESC, "createdAt", NULLS_LAST)) - in query I only see "order by *.createdAt desc"

So I don't know if it's a bug or not yet implemented feature but I just want to let you know

shouwn commented 1 week ago

Hi mikoaj-pe.

I didn't realize this didn't work, my guess is that Spring doesn't support nulls_first or nulls_last yet. https://github.com/spring-projects/spring-data-jpa/issues/1280

When I looked at the code in Spring, it also didn't support this yet. image

Probably because the Criteria API does not yet define interfaces for nulls_first or nulls_last.

Since Spring doesn't support it, it's unlikely that Kotlin JDSL will support it either.

If you want to use nulls_first or nulls_last, I recommend using the nullsFirst and nullsLast methods provided by Kotlin JDSL to handle them. image