Supports scrolling base on keyset without id#3013
Conversation
|
Removing the primary key isn't going to work, as Keyset scrolling must enforce uniqueness. Just accepting |
IMO, we should add a section in document to elaborate advantage and limitation, guide developers to make best decision, avoid making code more complex. |
|
I agree that we should improve the documentation in Commons to explain the relationship of |
|
I mean it is the responsibility of developer to make sure keys combination unique if the document emphasize that. |
|
Test improved to cover such cases:
all cases are tested against |
|
Please, let's keep pull requests focused instead of mixing concerns within a single pull request. |
Sorry to disturb you, those changes are related and necessary to make the test pass. |
|
We don't work towards making tests pass that combine various aspects but rather include coordinated changes. I applied the directional retention via #2999 already. Including unique sort arguments and checking for these requires a bit more changes than we have in this PR. Towards the sort requirements, we want the calling code to specify sort properties without the requirement to include always properties to make rows unique. Making rows unique is primarily a concern of our keyset scrolling code. If calling code wants to specify sort properties to make the result unique, then we can do so in the course of this pull request. |
071f270 to
1324b29
Compare
|
A viable proposal is adding a boolean property (eg. |
|
We could introduce a global property indicate that sort is unique ensured by developer. |
|
Commit updated, I introduce method |
52ee55f to
61e6d36
Compare
|
Hi @quaff, Have you considered nullable unique columns? In standard SQL, a UNIQUE constraint does not prevent multiple NULL values. If the database contains multiple rows where this column is NULL, relying solely on the unique flag for keyset scrolling without an explicit ID fallback might cause unexpected behavior or result in multiple rows being returned. It would be great to add a test case to ensure this works fine when multiple NULL values are present in the unique column. |
fede995 to
9191912
Compare
@stupid58fly Updated as you suggested, thanks. |
|
Thanks for the update! I have a couple of thoughts regarding the logic and future extensibility:
if (column != null) {
return column.unique() && !column.nullable();
}
What do you think? |
See spring-projectsGH-2996 Signed-off-by: Yanming Zhou <zhouyanming@gmail.com>
|
id shouldn't be added to sort if provided sort contains unique property.
See GH-2996