Fix Regression (#6376)

* failing test

* fix
This commit is contained in:
Nathan Doef 2024-10-17 07:12:21 -04:00 committed by GitHub
parent 4ab958a58f
commit 8f52f1c769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 28 additions and 2 deletions

View File

@ -1596,7 +1596,7 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
String sql = localReferenceQuery + " UNION " + canonicalQuery.getLeft(); String sql = localReferenceQuery + " UNION " + canonicalQuery.getLeft();
Map<String, Object> limitParams = null; Map<String, Object> limitParams = new HashMap<>();
if (maxCount != null) { if (maxCount != null) {
LinkedList<Object> bindVariables = new LinkedList<>(); LinkedList<Object> bindVariables = new LinkedList<>();
sql = SearchQueryBuilder.applyLimitToSql( sql = SearchQueryBuilder.applyLimitToSql(
@ -1605,7 +1605,6 @@ public class SearchBuilder implements ISearchBuilder<JpaPid> {
// The dialect SQL limiter uses positional params, but we're using // The dialect SQL limiter uses positional params, but we're using
// named params here, so we need to replace the positional params // named params here, so we need to replace the positional params
// with equivalent named ones // with equivalent named ones
limitParams = new HashMap<>(bindVariables.size());
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < sql.length(); i++) { for (int i = 0; i < sql.length(); i++) {
char nextChar = sql.charAt(i); char nextChar = sql.charAt(i);

View File

@ -2983,6 +2983,32 @@ public class ResourceProviderR4Test extends BaseResourceProviderR4Test {
assertEquals(10, bundle.getTotal()); assertEquals(10, bundle.getTotal());
} }
@Test
public void testIncludeWithNullMaxIncludesToLoad() {
myStorageSettings.setMaximumIncludesToLoadPerPage(null);
Organization org = new Organization();
org.setName("ORG");
IIdType orgId = myOrganizationDao.create(org, mySrd).getId().toUnqualifiedVersionless();
Patient pt = new Patient();
pt.getManagingOrganization().setReference(orgId.getValue());
pt.addName().setFamily("FAM");
myPatientDao.create(pt, mySrd);
Bundle bundle = myClient
.search()
.forResource(Patient.class)
.include(Patient.INCLUDE_ORGANIZATION)
.returnBundle(Bundle.class)
.execute();
ourLog.debug(myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
assertThat(bundle.getEntry()).hasSize(2);
assertEquals("Patient", bundle.getEntry().get(0).getResource().getIdElement().getResourceType());
assertEquals("Organization", bundle.getEntry().get(1).getResource().getIdElement().getResourceType());
}
@Test @Test
public void testIncludeWithExternalReferences() { public void testIncludeWithExternalReferences() {
myStorageSettings.setAllowExternalReferences(true); myStorageSettings.setAllowExternalReferences(true);

View File

@ -390,6 +390,7 @@ public abstract class BaseJpaTest extends BaseTest {
myStorageSettings.setAdvancedHSearchIndexing(defaultConfig.isAdvancedHSearchIndexing()); myStorageSettings.setAdvancedHSearchIndexing(defaultConfig.isAdvancedHSearchIndexing());
myStorageSettings.setAllowContainsSearches(defaultConfig.isAllowContainsSearches()); myStorageSettings.setAllowContainsSearches(defaultConfig.isAllowContainsSearches());
myStorageSettings.setIncludeHashIdentityForTokenSearches(defaultConfig.isIncludeHashIdentityForTokenSearches()); myStorageSettings.setIncludeHashIdentityForTokenSearches(defaultConfig.isIncludeHashIdentityForTokenSearches());
myStorageSettings.setMaximumIncludesToLoadPerPage(defaultConfig.getMaximumIncludesToLoadPerPage());
} }