-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow users sorting by either nulls first or nulls last. Example of usage: ```java Sort.by("foo", Sort.Direction.Ascending, Sort.NullHandling.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
- Loading branch information
Showing
10 changed files
with
175 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...t/src/test/java/io/quarkus/hibernate/orm/panache/deployment/test/PanacheSortTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.quarkus.hibernate.orm.panache.deployment.test; | ||
|
||
import static org.hamcrest.Matchers.is; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.extension.RegisterExtension; | ||
|
||
import io.quarkus.test.QuarkusUnitTest; | ||
import io.restassured.RestAssured; | ||
|
||
public class PanacheSortTestCase { | ||
@RegisterExtension | ||
final static QuarkusUnitTest TEST = new QuarkusUnitTest() | ||
.withApplicationRoot((jar) -> jar | ||
.addClasses(MyEntity.class, MyTestResource.class) | ||
.addAsResource("application-test.properties", "application.properties") | ||
.addAsResource("import.sql")); | ||
|
||
@Test | ||
public void testByNullFirstOptions() { | ||
RestAssured.when().get("/entity/list/by/nulls/first").then().statusCode(200) | ||
.body(is("[{\"id\":2},{\"id\":1,\"name\":\"my name\"}]")); | ||
} | ||
|
||
@Test | ||
public void testByNullLastOptions() { | ||
RestAssured.when().get("/entity/list/by/nulls/last").then().statusCode(200) | ||
.body(is("[{\"id\":1,\"name\":\"my name\"},{\"id\":2}]")); | ||
} | ||
} |
2 changes: 2 additions & 0 deletions
2
extensions/panache/hibernate-orm-panache/deployment/src/test/resources/import.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
INSERT INTO MyEntity(id, name) VALUES(1, 'my name'); | ||
-- To verify null columns sorting | ||
INSERT INTO MyEntity(id) VALUES(2); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters