-
Notifications
You must be signed in to change notification settings - Fork 198
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
Initial addition of cursored pagination for SQL #2884
Conversation
c1c1fe6
to
e3896d2
Compare
Could you look at the Jakarta Data spec https://github.com/jakartaee/data/blob/main/api/src/main/java/jakarta/data/page/CursoredPage.java And make sure we mirror that implementation as closely as possible |
Please target 4.8.x with adjusted |
e3896d2
to
449d0d2
Compare
Do you know how I can solve this error?
|
Looks like DB is out of connections. How do you get it? |
The AbstractCursoredPageSpec has a few parametrized tests that perhaps create many connections. But this error appears only when testing with PostgreSQL. |
I added similar |
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...jdbc/src/test/groovy/io/micronaut/data/jdbc/sqlserver/SqlServerCursoredPaginationSpec.groovy
Show resolved
Hide resolved
Can you please make an API closer to Jakarta Data? It would be nice to add |
data-model/src/main/java/io/micronaut/data/model/DefaultCursoredPageable.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
data-model/src/main/java/io/micronaut/data/model/CursoredPageable.java
Outdated
Show resolved
Hide resolved
data-model/src/main/java/io/micronaut/data/model/DefaultPageable.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Outdated
Show resolved
Hide resolved
...src/main/java/io/micronaut/data/runtime/operations/internal/sql/DefaultSqlPreparedQuery.java
Show resolved
Hide resolved
data-model/src/main/java/io/micronaut/data/model/DefaultCursoredPageable.java
Show resolved
Hide resolved
data-model/src/main/java/io/micronaut/data/model/DefaultCursoredPageable.java
Show resolved
Hide resolved
Can you also add tests for R2dbc and Hibernate? |
- Create the CursoredPageable type. - Modify the DefaultSqlPreparedQuery to support cursored pageable for SQL. - Modify DefaultFindPageInterceptor to return correct pageable for further pagination in cursored case.
ff2acd6
to
5146d90
Compare
a881e77
to
019dacd
Compare
…d previousPageable implementation from the CursoredPageable
data-model/src/main/java/io/micronaut/data/model/DefaultCursoredPageable.java
Show resolved
Hide resolved
data-model/src/main/java/io/micronaut/data/model/DefaultCursoredPage.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It misses documentation.
|
||
@Override | ||
void init() { | ||
context = ApplicationContext.run(properties) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Less important, I think you could move context creation in the abstract class
@AutoCleanup
@Shared
ApplicationContext context = ApplicationContext.run(properties)
and then use it in all tests (usually how we do it) so init() method might not be needed.
...r2dbc/src/test/groovy/io/micronaut/data/r2dbc/postgres/PostgresCursoredPaginationSpec.groovy
Outdated
Show resolved
Hide resolved
@andriy-dmytruk Let's try to finish this PR, the only thing that is missing is the documentation and maybe the changes you mentioned regarding the DefaultCursoredPage |
Quality Gate failedFailed conditions See analysis details on SonarCloud Catch issues before they fail your Quality Gate with our IDE extension SonarLint |
@dstepanov and @sdelamo could you take another look? |
Guide for the Cursor-based pagination support added to Micronaut Data JDBC by this [PR #2884](micronaut-projects/micronaut-data#2884) We cannot merge this PR until the framework 4.5.0 release which will contain a Micronaut Data release with that feature. You can generate the guide’s HTML locally with : ``` ./gradlew build open build/dist/micronaut-data-cursored-page-gradle-java.html ``` To run the sample code locally, publish to maven local Micronaut Data PR and use: ``` annotationProcessor("io.micronaut.data:micronaut-data-processor:4.8.0-SNAPSHOT") implementation("io.micronaut.data:micronaut-data-jdbc:4.8.0-SNAPSHOT") ```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a guide which we can publish once we have framework release which contains a data release with this feature.
@sdelamo It would be nice to show how to propagate the cursor to the FE |
This is an initial PR to check if this approach could be considered.
CursoredPageable
type.DefaultSqlPreparedQuery
to support cursored pageable for SQL. Since cursored pagination requires a new query part with parameters, the type was modified with additional query bindings.DefaultFindPageInterceptor
to return the correct pageable for further pagination in the cursored case.Other interceptors will further need to be changed for this to work in all cases, like the
FindPageSpecificationInterceptor
. Additionally, the cursor could be encoded to base 64 instead of a JSON array. It seems likePageabe.hasNext()
method would also be beneficial. Should that be added to both offset and cursor pagination?