Satish11012007 opened a new pull request, #5606:
URL: https://github.com/apache/fineract/pull/5606

   ## Description
   
   This PR fixes an issue where calling the Stretchy Reports endpoint with 
`template=true` still attempted to execute the underlying SQL query.
   
   Stretchy report queries often contain placeholders such as `${officeId}{}` 
or `${currencyId}{}` which are meant to be replaced with request parameters. 
When `template=true` is used, the expected behavior is to return report 
parameter metadata without executing the SQL query.
   
   However, the existing implementation did not properly handle the `template` 
flag. As a result, the SQL query was executed with unresolved placeholders, 
which caused PostgreSQL to throw errors such as:
   
   org.postgresql.util.PSQLException: ERROR: syntax error at or near "$"
   
   This PR resolves the issue by ensuring that when `template=true` is present 
in the request and `parameterType` is not explicitly provided, the system 
automatically treats the request as a parameter metadata request by setting 
`parameterType=true`.
   
   This prevents SQL execution and returns the required report parameter 
metadata as intended.
   
   Fixes: FINERACT-1556
   
   
   ## Changes Made
   
   - Updated `RunreportsApiResource.processReportRequest` to ensure that 
`template=true` implies `parameterType=true` when `parameterType` is not 
explicitly provided.
   - Prevented execution of report SQL queries when the request is meant to 
fetch parameter metadata.
   - Added regression tests to validate correct propagation of the `template` 
flag.
   
   
   ## Files Modified
   
   - 
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResource.java
   - 
fineract-provider/src/test/java/org/apache/fineract/infrastructure/dataqueries/api/RunreportsApiResourceTest.java
   
   
   ## Testing
   
   Added unit tests to verify that requests with `template=true` correctly 
propagate as `parameterType=true`.
   
   Commands used:
   
   ./gradlew :fineract-provider:test --tests 
org.apache.fineract.infrastructure.dataqueries.api.RunreportsApiResourceTest
   
   ./gradlew :fineract-provider:test
   
   Result:
   
   All tests passed successfully.
   
   
   ## How to Verify
   
   Call the following API:
   
   GET 
/fineract-provider/api/v1/runreports/Active%20Loans%20-%20Details?template=true
   
   Expected behavior:
   
   - The API returns report parameter metadata
   - The SQL query is not executed
   - No PostgreSQL `$` placeholder errors occur
   
   
   ## Checklist
   
   - [x] Write the commit message as per our guidelines
   - [x] Ensure the build passes successfully
   - [x] Create/update unit tests verifying the changes
   - [x] Follow Apache Fineract coding conventions
   - [ ] Add Swagger annotation / API documentation update (not required as no 
API contract change)
   - [x] PR is focused and not a code dump
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to