fix(config): add missing ORDER BY to Derby pagination queries#14748
Merged
Conversation
Several pagination methods in ConfigInfoMapperByDerby use OFFSET/FETCH NEXT without ORDER BY, causing non-deterministic results across pages. This adds ORDER BY before OFFSET to all affected methods. Also adds orderBy() method to WhereBuilder.
|
Thanks for your this PR. 🙏 感谢您提交的PR。 🙏 |
KomachiSion
approved these changes
Mar 31, 2026
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Several pagination methods in
ConfigInfoMapperByDerbyuseOFFSET/FETCH NEXTwithoutORDER BY, causing non-deterministic results across paginated requests. This is the Derby dialect equivalent of the MySQL bug reported in #14046.Root Cause
Derby does not guarantee consistent row ordering without an explicit
ORDER BYclause. WhenOFFSET/FETCH NEXTis used for pagination, different pages may return overlapping or missing records.Fix
Added
ORDER BYbeforeOFFSETin all affected methods:ConfigInfoMapperByDerby (8 methods):
findConfigInfoByAppFetchRows— addedORDER BY idgetTenantIdList— addedORDER BY tenant_idgetGroupIdList— addedORDER BY group_idfindChangeConfigFetchRows— addedORDER BY idfindConfigInfoBaseLikeFetchRows— addedORDER BY idfindConfigInfo4PageFetchRows— addedORDER BY idfindConfigInfoBaseByGroupFetchRows— addedORDER BY idfindConfigInfoLike4PageFetchRows— addedorderBy("id")via WhereBuilderAlso added
orderBy()method toWhereBuilderfor fluent ORDER BY support.Tests Added
All 8 corresponding test methods updated to verify the ORDER BY clause is present in the generated SQL.
Impact
Ensures deterministic pagination ordering for all Derby config queries. Consistent with existing methods in the same class that already use
ORDER BY id.