ezolnbl-dpc commented on code in PR #2659:
URL: https://github.com/apache/fineract/pull/2659#discussion_r994865196
##########
fineract-provider/src/main/java/org/apache/fineract/infrastructure/dataqueries/service/ReadWriteNonCoreDataServiceImpl.java:
##########
@@ -183,6 +192,116 @@ public DatatableData retrieveDatatable(final String
datatable) {
return datatableData;
}
+ @Override
+ public List<JsonObject> queryDataTable(String datatable, String
columnFilter, String valueFilter, String resultColumns) {
+ Arrays.asList(datatable, columnFilter, valueFilter,
resultColumns).forEach(SQLInjectionValidator::validateDynamicQuery);
+ List<String> resultColumnNames =
Stream.of(resultColumns.split(",")).toList();
+ String sql = "select " + resultColumns + " from " + datatable + "
where " + columnFilter + " = ?";
+
+ List<ResultsetColumnHeaderData> resultsetColumnHeaderData =
genericDataService.fillResultsetColumnHeaders(datatable);
+ Object finalValueFilter = valueFilter;
+ SqlRowSet rowSet = null;
+ String filterColumnType =
resultsetColumnHeaderData.stream().filter(column ->
columnFilter.equals(column.getColumnName()))
+
.findFirst().map(ResultsetColumnHeaderData::getColumnType).orElse(columnFilter
+ " does not exist in datatable");
+ if (databaseTypeResolver.isPostgreSQL()) {
+ int[] argType = new int[1];
+ if ("bit".equalsIgnoreCase(filterColumnType)) {
+ finalValueFilter =
BooleanUtils.toString(BooleanUtils.toBooleanObject(valueFilter), "1", "0",
"null");
+ argType[0] = Types.BIT;
+ } else if ("boolean".equalsIgnoreCase(filterColumnType) ||
"bool".equalsIgnoreCase(filterColumnType)) {
+ finalValueFilter =
BooleanUtils.toString(BooleanUtils.toBooleanObject(valueFilter), "true",
"false", "null");
+ argType[0] = Types.BOOLEAN;
+ } else if ("integer".equalsIgnoreCase(filterColumnType)) {
Review Comment:
you made a change at 2022.02.22 putting a TODO comment in that service class:
// TODO: Extract these types out of here
`.put("text", "TEXT").put("dropdown", "INT").build();`
Those strings could be also reused or extracted.
Also there are countless occurrences of various column type names scattered
in the code.
If the scope of this ticket is to refactor the codebase from database
specific column type names, I will gladly do it but I don't think now is the
time, it does not bring any real value. Nobody will search the entire codebase
in a approx ~423.000 line project for reusable texts for words like "boolean"
and "integer".
--
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]