Skip to content

GH-821 Add support for specifying ORDER BY null handling for supported dialects #1156

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 9 commits into from

Conversation

ctailor2
Copy link
Contributor

@ctailor2 ctailor2 commented Feb 3, 2022

This adds support for specifying how null values should be handled when ordering query results, via the NULLS FIRST and NULLS LAST options, for stores conforming to the SQL standard.

Dialects for which null handling support was added:

  • DB2
  • H2
  • HSQL
  • Oracle
  • Postgres

Dialects with no current support for null handling:

  • MySQL
  • MariaDB
  • Sql Server

Closes #821

@ctailor2 ctailor2 requested a review from schauder February 3, 2022 19:39
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Feb 3, 2022
Copy link
Contributor

@schauder schauder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good work.

I left a couple of comments. Just small stuff.

* @author Chirag Tailor
*/
public interface OrderByOptionsSupport {
String resolve(@Nullable Sort.Direction direction, Sort.NullHandling nullHandling);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also think this function lacks documentation. It is not clear from the first glance, ( at leas for me :) ) what exactly resolve function does. Maybe we can add javadoc upon it? @ctailor2 Chirag, what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed @mikhail2048, it wasn't very clear and I think that is largely because the two related but distinct concepts of Sort.Direction and Sort.NullHandling shouldn't be coupled together here. I moved the direction handling back out and and repurposed this interface to be for Sort.NullHandling only which hopefully makes the code more clear. I also added some more javadocs. Could you review my latest changes to see if these updates improve upon this?

Move ORDER BY direction evaluation back into OrderByClauseVisitor.
This makes the implementation more explicit and resilient to possible upstream code changes.
schauder pushed a commit that referenced this pull request Feb 8, 2022
schauder added a commit that referenced this pull request Feb 8, 2022
Rename "null handling" to "null precedence".
This is somewhat inconsistent with commons null handling, but more descriptive.

Minor formatting.

Original pull request #1156
See #821
@schauder
Copy link
Contributor

schauder commented Feb 8, 2022

Thanks. That's polished and merged.

@schauder schauder closed this Feb 8, 2022
@schauder schauder deleted the issue/821-support-sort-null-handling branch February 8, 2022 11:13
schauder pushed a commit that referenced this pull request Feb 15, 2022
schauder added a commit that referenced this pull request Feb 15, 2022
Rename "null handling" to "null precedence".
This is somewhat inconsistent with commons null handling, but more descriptive.

Minor formatting.

Original pull request #1156
See #821
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: waiting-for-triage An issue we've not yet triaged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Sort.NullHandling [DATAJDBC-599]
4 participants