You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@fineract.apache.org by GitBox <gi...@apache.org> on 2022/06/13 12:56:56 UTC

[GitHub] [fineract] josehernandezfintecheandomx commented on a diff in pull request #2354: Fix for reading multirow datatable entry reads non-belonging entry

josehernandezfintecheandomx commented on code in PR #2354:
URL: https://github.com/apache/fineract/pull/2354#discussion_r895685211


##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java:
##########
@@ -1304,18 +1334,19 @@ private GenericResultsetData retrieveDataTableGenericResultSetForUpdate(final St
 
         final List<ResultsetColumnHeaderData> columnHeaders = this.genericDataService.fillResultsetColumnHeaders(dataTableName);
 
-        String sql = "";
+        final boolean multiRow = isMultirowDatatable(columnHeaders);
 
-        // id only used for reading a specific entry in a one to many datatable
-        // (when updating)
-        if (id == null) {
-            String whereClause = getFKField(appTable) + " = " + appTableId;
-            SQLInjectionValidator.validateSQLInput(whereClause);
-            sql = sql + "select * from " + sqlGenerator.escape(dataTableName) + " where " + whereClause;
-        } else {
-            sql = sql + "select * from " + sqlGenerator.escape(dataTableName) + " where id = " + id;
+        String whereClause = getFKField(appTable) + " = " + appTableId;
+        SQLInjectionValidator.validateSQLInput(whereClause);
+        String sql = "select * from " + sqlGenerator.escape(dataTableName) + " where " + whereClause;
+
+        // id only used for reading a specific entry that belongs to appTableId (in a one to many datatable)
+        if (multiRow && id != null) {
+            sql = sql + " and id = " + id;
         }
 
+        LOG.info(sql);

Review Comment:
   Done!



-- 
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: commits-unsubscribe@fineract.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org