FINERACT-2013: Fix case-sensitive limit offset removal in count query#6146
Open
Yashgoswami-ds wants to merge 2 commits into
Open
FINERACT-2013: Fix case-sensitive limit offset removal in count query#6146Yashgoswami-ds wants to merge 2 commits into
Yashgoswami-ds wants to merge 2 commits into
Conversation
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.
Description
This PR fixes an issue in the audit pagination count query where the API returned an incorrect
totalFilteredRecordsvalue even when audit records were present.Issue
When calling the audit API with pagination enabled:
The API returned:
{ "totalFilteredRecords": 0, "pageItems": [] }despite audit records being available in the
m_portfolio_command_sourcetable.Root Cause
The issue was identified in
DatabaseSpecificSQLGenerator, which is responsible for generating the count query used for paginated responses.The existing implementation attempted to remove
LIMITandOFFSETclauses using case-sensitive regular expressions:However, the SQL generated by the pagination flow used lowercase keywords:
Since the regular expressions were case-sensitive, the
LIMITandOFFSETclauses were not removed from the SQL.As a result, the generated count query still contained the pagination clauses:
This caused the count query to operate on the paginated result set instead of the complete result set, leading to an incorrect
totalFilteredRecordsvalue.Solution
Updated the regular expressions to remove
LIMITandOFFSETin a case-insensitive manner:Using the
(?i)flag ensures that SQL keywords are matched regardless of their case (LIMIT,limit,Limit, etc.), allowing the count query to be generated correctly.Verification
The issue was reproduced and verified locally using Docker with PostgreSQL.
Before the fix
{ "totalFilteredRecords": 0, "pageItems": [] }After the fix
{ "totalFilteredRecords": 3, "pageItems": [ { "id": 3, "actionName": "CREATE", "entityName": "CLIENT" } ] }After applying the fix, the audit pagination endpoint correctly returns both the total number of matching audit records and the expected paginated results.
Testing Environment
developbranch