This commit is contained in:
David 2024-09-26 15:37:57 -04:00 committed by GitHub
commit 061261068f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 0 deletions

View File

@ -0,0 +1,3 @@
type: fix
issue: 6199
title: "Fix for an mssql runtime error when searching for resources with the _include clause."

View File

@ -115,6 +115,7 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.Validate;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.hibernate.dialect.SQLServerDialect;
import org.hl7.fhir.instance.model.api.IAnyResource;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.slf4j.Logger;
@ -1584,6 +1585,10 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
String sql = localReferenceQuery + " UNION " + canonicalQuery.getLeft();
if (myDialectProvider.getDialect() instanceof SQLServerDialect) {
sql += " order by r." + findPidFieldSqlColumn;
}
List<Collection<JpaPid>> partitions = partition(nextRoundMatches, getMaximumPageSize());
for (Collection<JpaPid> nextPartition : partitions) {
Query q = entityManager.createNativeQuery(sql, Tuple.class);