2843 questionnaire include url fix (#3447)

* Added test to verify BUG: #2843 (_include doesn't return canonically referred resource)

* Fix '_include' query search by native query to support canonical url references

* Fixed code review comments

* Restored the res_type condition on join
This commit is contained in:
Jaison Baskaran 2022-03-07 09:39:13 -07:00 committed by GitHub
parent 62bcb80443
commit abea0389be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -1053,15 +1053,17 @@ public class SearchBuilder implements ISearchBuilder {
} }
} }
//@formatter:off //@formatter:off
StringBuilder resourceUrlBasedQuery = new StringBuilder("SELECT " + fieldsToLoadFromSpidxUriTable + String resourceUrlBasedQuery = "SELECT " + fieldsToLoadFromSpidxUriTable +
" FROM hfj_res_link r " + " FROM hfj_res_link r " +
" JOIN hfj_spidx_uri rUri ON ( " + " JOIN hfj_spidx_uri rUri ON ( " +
" r.target_resource_url = rUri.sp_uri AND " + " r.target_resource_url = rUri.sp_uri AND " +
" rUri.sp_name = 'url' " + " rUri.sp_name = 'url' " +
(targetResourceType != null ? " AND rUri.res_type = :target_resource_type " : "") +
(haveTargetTypesDefinedByParam ? " AND rUri.res_type IN (:target_resource_types) " : "") +
" ) " + " ) " +
" WHERE r.src_path = :src_path AND " + " WHERE r.src_path = :src_path AND " +
" r.target_resource_id IS NULL AND " + " r.target_resource_id IS NULL AND " +
" r." + searchPidFieldSqlColumn + " IN (:target_pids) "); " r." + searchPidFieldSqlColumn + " IN (:target_pids) ";
//@formatter:on //@formatter:on
String sql = resourceIdBasedQuery + " UNION " + resourceUrlBasedQuery; String sql = resourceIdBasedQuery + " UNION " + resourceUrlBasedQuery;