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


##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "
+                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search )) "
                 + " order by g.id desc";
 
         final StringBuilder sql = new StringBuilder();
 
         if (searchConditions.isClientSearch()) {
-            sql.append(clientMatchSql).append(union);
+            sql.append("(" + clientMatchSql + ")").append(union);

Review Comment:
   Done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "

Review Comment:
   No, none of the others filters by id and there is an error to compare bigint 
ans¡d string



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "
+                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search )) "
                 + " order by g.id desc";
 
         final StringBuilder sql = new StringBuilder();
 
         if (searchConditions.isClientSearch()) {
-            sql.append(clientMatchSql).append(union);
+            sql.append("(" + clientMatchSql + ")").append(union);
         }
 
         if (searchConditions.isLoanSeach()) {
-            sql.append(loanMatchSql).append(union);
+            sql.append("(" + loanMatchSql + ")").append(union);
         }
 
         if (searchConditions.isSavingSeach()) {
-            sql.append(savingMatchSql).append(union);
+            sql.append("(" + savingMatchSql + ")").append(union);
         }
 
         if (searchConditions.isShareSeach()) {
-            sql.append(shareMatchSql).append(union);
+            sql.append("(" + shareMatchSql + ")").append(union);
         }
 
         if (searchConditions.isClientIdentifierSearch()) {
-            sql.append(clientIdentifierMatchSql).append(union);
+            sql.append("(" + clientIdentifierMatchSql + ")").append(union);

Review Comment:
   Done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "
+                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search )) "
                 + " order by g.id desc";
 
         final StringBuilder sql = new StringBuilder();
 
         if (searchConditions.isClientSearch()) {
-            sql.append(clientMatchSql).append(union);
+            sql.append("(" + clientMatchSql + ")").append(union);
         }
 
         if (searchConditions.isLoanSeach()) {
-            sql.append(loanMatchSql).append(union);
+            sql.append("(" + loanMatchSql + ")").append(union);
         }
 
         if (searchConditions.isSavingSeach()) {
-            sql.append(savingMatchSql).append(union);
+            sql.append("(" + savingMatchSql + ")").append(union);
         }
 
         if (searchConditions.isShareSeach()) {
-            sql.append(shareMatchSql).append(union);
+            sql.append("(" + shareMatchSql + ")").append(union);

Review Comment:
   Done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -90,7 +90,7 @@ public String searchSchema(final SearchConditions 
searchConditions) {
                 + " order by l.id desc";
 
         final String savingMatchSql = " (select 'SAVING' as entityType, s.id 
as entityId, sp.name as entityName, s.external_id as entityExternalId, 
s.account_no as entityAccountNo "
-                + " , coalesce(c.id,g.id) as parentId, 
coalesce(c.display_name,g.display_name) as parentName, null as entityMobileNo, 
s.status_enum as entityStatusEnum, s.deposit_type_enum as subEntityType, CASE 
WHEN g.id is null THEN 'client' ELSE 'group' END as parentType "
+                + " , coalesce(c.id,g.id) as parentId, 
coalesce(c.display_name, g.display_name) as parentName, null as entityMobileNo, 
s.status_enum as entityStatusEnum, concat(s.deposit_type_enum, '') as 
subEntityType, CASE WHEN g.id is null THEN 'client' ELSE 'group' END as 
parentType "

Review Comment:
   If we leave the original SQL we get an error when we use more than one 
resource why? because the column subEntityType (as you have viewed) in almost 
all the SQL uses null (the null is considered as string type by the RDBMS) and 
in the Savings SQL filter It has a value for the Savings attribute 
deposit_type_enum (int type) and that difference to the RDBMS generates tan 
error, so It is not possible to manage after run the SQL in the mapper
   



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "

Review Comment:
   No, none of the others filters by id and there is an error to compare bigint 
ans¡d string



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "
+                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search )) "
                 + " order by g.id desc";
 
         final StringBuilder sql = new StringBuilder();
 
         if (searchConditions.isClientSearch()) {
-            sql.append(clientMatchSql).append(union);
+            sql.append("(" + clientMatchSql + ")").append(union);
         }
 
         if (searchConditions.isLoanSeach()) {
-            sql.append(loanMatchSql).append(union);
+            sql.append("(" + loanMatchSql + ")").append(union);
         }
 
         if (searchConditions.isSavingSeach()) {
-            sql.append(savingMatchSql).append(union);
+            sql.append("(" + savingMatchSql + ")").append(union);
         }
 
         if (searchConditions.isShareSeach()) {
-            sql.append(shareMatchSql).append(union);
+            sql.append("(" + shareMatchSql + ")").append(union);
         }
 
         if (searchConditions.isClientIdentifierSearch()) {
-            sql.append(clientIdentifierMatchSql).append(union);
+            sql.append("(" + clientIdentifierMatchSql + ")").append(union);
         }
 
         if (searchConditions.isGroupSearch()) {
-            sql.append(groupMatchSql).append(union);
+            sql.append("(" + groupMatchSql + ")").append(union);

Review Comment:
   Done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "

Review Comment:
   The answer is No, the group id filter is not used more for the next reasons;
   - None of the others filters use the filter by id (bigint)
   - The RDBMS sends an error about to compare the id (bigint) against query 
(string)



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "
+                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search )) "
                 + " order by g.id desc";
 
         final StringBuilder sql = new StringBuilder();
 
         if (searchConditions.isClientSearch()) {
-            sql.append(clientMatchSql).append(union);
+            sql.append("(" + clientMatchSql + ")").append(union);
         }
 
         if (searchConditions.isLoanSeach()) {
-            sql.append(loanMatchSql).append(union);
+            sql.append("(" + loanMatchSql + ")").append(union);
         }
 
         if (searchConditions.isSavingSeach()) {
-            sql.append(savingMatchSql).append(union);
+            sql.append("(" + savingMatchSql + ")").append(union);

Review Comment:
   done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -108,33 +108,33 @@ public String searchSchema(final SearchConditions 
searchConditions) {
 
         final String groupMatchSql = " (select CASE WHEN g.level_id=1 THEN 
'CENTER' ELSE 'GROUP' END as entityType, g.id as entityId, g.display_name as 
entityName, g.external_id as entityExternalId, g.account_no as entityAccountNo, 
"
                 + " g.office_id as parentId, o.name as parentName, null as 
entityMobileNo, g.status_enum as entityStatusEnum, null as subEntityType, null 
as parentType "
-                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search or g.id like :search )) "
+                + " from m_group g join m_office o on o.id = g.office_id where 
o.hierarchy like :hierarchy and (g.account_no like :search or g.display_name 
like :search or g.external_id like :search )) "
                 + " order by g.id desc";
 
         final StringBuilder sql = new StringBuilder();
 
         if (searchConditions.isClientSearch()) {
-            sql.append(clientMatchSql).append(union);
+            sql.append("(" + clientMatchSql + ")").append(union);
         }
 
         if (searchConditions.isLoanSeach()) {
-            sql.append(loanMatchSql).append(union);
+            sql.append("(" + loanMatchSql + ")").append(union);

Review Comment:
   Done



##########
fineract-provider/src/main/java/org/apache/fineract/portfolio/search/service/SearchReadPlatformServiceImpl.java:
##########
@@ -90,7 +90,7 @@ public String searchSchema(final SearchConditions 
searchConditions) {
                 + " order by l.id desc";
 
         final String savingMatchSql = " (select 'SAVING' as entityType, s.id 
as entityId, sp.name as entityName, s.external_id as entityExternalId, 
s.account_no as entityAccountNo "
-                + " , coalesce(c.id,g.id) as parentId, 
coalesce(c.display_name,g.display_name) as parentName, null as entityMobileNo, 
s.status_enum as entityStatusEnum, s.deposit_type_enum as subEntityType, CASE 
WHEN g.id is null THEN 'client' ELSE 'group' END as parentType "
+                + " , coalesce(c.id,g.id) as parentId, 
coalesce(c.display_name, g.display_name) as parentName, null as entityMobileNo, 
s.status_enum as entityStatusEnum, concat(s.deposit_type_enum, '') as 
subEntityType, CASE WHEN g.id is null THEN 'client' ELSE 'group' END as 
parentType "

Review Comment:
   The reason to have this is because the RDBMS can not have in the same column 
strings (due the nulls) and integer for the Savings for the column deposit types



-- 
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