Coder Social home page Coder Social logo

Comments (8)

beikov avatar beikov commented on July 18, 2024 1

It is correct that Blaze-Persistence will always generate proper HQL that includes either null first or nulls last if the expression you order by is nullable. This shouldn't be a problem though if the null ordering you use matches the database default. I don't know which database you use, but e.g. H2 and MySQL treat null as the smallest element, so when you sort ascending, then nulls first is the default and for descending sorting, nulls last is the default. PostgreSQL and Oracle for example behave the other way around. There nulls last is the default for asc and nulls first the default for desc. Just match the default.

from blaze-persistence.

beikov avatar beikov commented on July 18, 2024

Hi! There is no option to change the default. That default is encoded into the implementation on purpose, for exactly the reason that you quoted, so that you choose a null precedence that fits your needs :)

from blaze-persistence.

zhanglc avatar zhanglc commented on July 18, 2024

Hi! There is no option to change the default. That default is encoded into the implementation on purpose, for exactly the reason that you quoted, so that you choose a null precedence that fits your needs :)

@beikov how to choose null precedence ?

from blaze-persistence.

beikov avatar beikov commented on July 18, 2024

You just add a second argument to orderByAsc or orderByDesc that specifies whether nulls should be first/last.

from blaze-persistence.

zhanglc avatar zhanglc commented on July 18, 2024

Thanks for the reply, is there no way to remove nulls first / nulls last with the current version ?

from blaze-persistence.

beikov avatar beikov commented on July 18, 2024

The only way to not render null first / nulls last in the resulting SQL is by using the same null precedence as the underlying database.

from blaze-persistence.

zhanglc avatar zhanglc commented on July 18, 2024

@beikov
I'm very sorry to reopen this issue. I found some code that looks like, blaze persistence doesn't support order's null default ?

if (nullable) {
if (orderBy.nullFirst == inverseOrder) {
sb.append(" NULLS LAST");
} else {
sb.append(" NULLS FIRST");
}
}

If I pass in a null default, nullFirst is false and the sql will be append with order by A null last.

Am I understanding this correctly?
I want to change this behavior, how do I do it, thank you very much!

from blaze-persistence.

zhanglc avatar zhanglc commented on July 18, 2024

@beikov thanks a lot .
We use PostgreSQL , It works well as change the code to the ones you've hinted.

Thanks a lot.

from blaze-persistence.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.