Skip to content
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

Support Panache Sort Null Handling #26394

Merged
merged 1 commit into from Jul 4, 2022
Merged

Conversation

Sgitario
Copy link
Contributor

@Sgitario Sgitario commented Jun 28, 2022

Allow users sorting by either nulls first or nulls last.
Example of usage:

Sort.by("foo", Sort.Direction.Ascending, Sort.NullPrecedence.NULLS_FIRST);

(See more examples in tests)

This PR also adds support of nulls handling for the Spring Data JPA Quarkus extension: it translates the Spring Sort object to the new Panache Sort object.

Finally, as the Panache Sort API is also used by the Mongo Quarkus extension and Mongo does not easily support sorting by nulls, I decided to simply print a WARNING message if users try to use it.

Fix #26172

@quarkus-bot quarkus-bot bot added area/panache area/spring Issues relating to the Spring integration labels Jun 28, 2022
@geoand
Copy link
Contributor

geoand commented Jun 28, 2022

I like the idea!

@loicmathieu WDYT?

@loicmathieu
Copy link
Contributor

I like the idea, I'll try to review the PR tomorrow or Friday.

On Mongo, we should not create methods that allow to set the NullHandling if not supported, or we should throw an error not log a warning as it's a developer mistake.

@Sgitario
Copy link
Contributor Author

Sgitario commented Jun 28, 2022

I like the idea, I'll try to review the PR tomorrow or Friday.

On Mongo, we should not create methods that allow to set the NullHandling if not supported, or we should throw an error not log a warning as it's a developer mistake.

The methods are common for the non-Mongo extensions, but it makes sense to throw an exception instead. PR updated.

Copy link
Contributor

@gastaldi gastaldi left a comment

Choose a reason for hiding this comment

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

LGTM

@gastaldi gastaldi requested a review from loicmathieu July 1, 2022 12:15
@gastaldi
Copy link
Contributor

gastaldi commented Jul 1, 2022

I think it would be nice to have this new feature documented in the Panache guides too.

@gastaldi
Copy link
Contributor

gastaldi commented Jul 1, 2022

Also don't forget to change the snippet in the commit to use NullPrecendence instead of NullHandling 😉

Copy link
Contributor

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

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

Can you also add some tests for MongoDB ? In existing test cases.

@Sgitario
Copy link
Contributor Author

Sgitario commented Jul 1, 2022

| Can you also add some tests for MongoDB ? In existing test cases.

@loicmathieu do you mean to verify that the exception is thrown when using NullPrecedence in MongoDB ?

@loicmathieu
Copy link
Contributor

@Sgitario yes

@Sgitario
Copy link
Contributor Author

Sgitario commented Jul 1, 2022

I've just updated the PR's changes with:

  • documentation
  • integration tests in reactive, orm and mongodb

@Sgitario Sgitario requested a review from loicmathieu July 1, 2022 14:35
Copy link
Contributor

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

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

I added a bunch of JavaDoc suggestions, mainly due to the renaming of handlin -> precedence but overall looks good to me.

Can you please also update the Hibernate reactive guide Sort section: https://quarkus.io/guides/hibernate-reactive-panache#sorting

@quarkus-bot

This comment has been minimized.

@quarkus-bot

This comment has been minimized.

@Sgitario Sgitario requested a review from loicmathieu July 1, 2022 16:09
@quarkus-bot

This comment has been minimized.

@Sgitario
Copy link
Contributor Author

Sgitario commented Jul 1, 2022

Documentation for Panache Reactive also updated.

@quarkus-bot

This comment has been minimized.

Allow users sorting by either nulls first or nulls last.
Example of usage:

```java
Sort.by("foo", Sort.Direction.Ascending, Sort.NullPrecedence.NULLS_FIRST);
```

(See more examples in tests)

This PR also adds support of nulls handling for the Spring Data JPA Quarkus extension: it translates the Spring Sort object to the new Panache Sort object. 

Finally, as the Panache Sort API is also used by the Mongo Quarkus extension and Mongo does not easily support sorting by nulls, I decided to simply print a WARNING message if users try to use it.

Fix quarkusio#26172
@gastaldi gastaldi added the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 1, 2022
Copy link
Contributor

@loicmathieu loicmathieu left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for your contribution

@loicmathieu loicmathieu removed the triage/waiting-for-ci Ready to merge when CI successfully finishes label Jul 4, 2022
@loicmathieu loicmathieu added this to the 2.11 - main milestone Jul 4, 2022
@geoand geoand merged commit ebd7da0 into quarkusio:main Jul 4, 2022
@quarkus-bot quarkus-bot bot added the kind/enhancement New feature or request label Jul 4, 2022
@Sgitario Sgitario deleted the spring_nulls branch July 19, 2022 13:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/documentation area/mongodb area/panache area/spring Issues relating to the Spring integration kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spring Data JPA sorting with NullHandling parameter
4 participants