diff --git a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
index 124e3668ee1..4e30159e585 100644
--- a/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
+++ b/hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/dao/SearchBuilder.java
@@ -1676,8 +1676,6 @@ public class SearchBuilder implements ISearchBuilder {
Predicate predicate;
if ((operation == null) ||
- (operation == SearchFilterParser.CompareOperation.eq) ||
- (operation == SearchFilterParser.CompareOperation.co) ||
(operation == SearchFilterParser.CompareOperation.sw) ||
(operation == SearchFilterParser.CompareOperation.ew)) {
@@ -1685,6 +1683,11 @@ public class SearchBuilder implements ISearchBuilder {
Predicate hashCode = theBuilder.equal(theFrom.get("myHashNormalizedPrefix").as(Long.class), hash);
Predicate singleCode = theBuilder.like(theFrom.get("myValueNormalized").as(String.class), likeExpression);
predicate = theBuilder.and(hashCode, singleCode);
+ } else if (operation == SearchFilterParser.CompareOperation.eq) {
+ Long hash = ResourceIndexedSearchParamString.calculateHashNormalized(myDaoConfig.getModelConfig(), theResourceName, theParamName, normalizedString);
+ Predicate hashCode = theBuilder.equal(theFrom.get("myHashNormalizedPrefix").as(Long.class), hash);
+ Predicate singleCode = theBuilder.like(theFrom.get("myValueNormalized").as(String.class), normalizedString);
+ predicate = theBuilder.and(hashCode, singleCode);
} else if (operation == SearchFilterParser.CompareOperation.ne) {
Predicate singleCode = theBuilder.notEqual(theFrom.get("myValueNormalized").as(String.class), likeExpression);
predicate = combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, theFrom, singleCode);
@@ -1701,7 +1704,7 @@ public class SearchBuilder implements ISearchBuilder {
Predicate singleCode = theBuilder.lessThanOrEqualTo(theFrom.get("myValueNormalized").as(String.class), likeExpression);
predicate = combineParamIndexPredicateWithParamNamePredicate(theResourceName, theParamName, theFrom, singleCode);
} else {
- throw new IllegalArgumentException("Unknown operation type: " + operation);
+ throw new IllegalArgumentException("Don't yet know how to handle operation " + operation + " on a string");
}
return predicate;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4FilterTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4FilterTest.java
index cfecc19072f..9088233c5f3 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4FilterTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4FilterTest.java
@@ -6,15 +6,18 @@ import ca.uhn.fhir.jpa.util.TestUtil;
import ca.uhn.fhir.rest.api.Constants;
import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
+import org.hamcrest.Matchers;
import org.hl7.fhir.r4.model.Patient;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
+import org.mockito.ArgumentMatchers;
import java.util.List;
import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.hamcrest.Matchers.emptyString;
import static org.junit.Assert.*;
@SuppressWarnings({"Duplicates"})
@@ -44,7 +47,7 @@ public class FhirResourceDaoR4FilterTest extends BaseJpaR4Test {
}
@Test
- public void testChainWithMultipleTypePossibilities() {
+ public void testBrackets() {
Patient p= new Patient();
p.addName().setFamily("Smith").addGiven("John");
@@ -73,6 +76,36 @@ public class FhirResourceDaoR4FilterTest extends BaseJpaR4Test {
}
+ @Test
+ public void testStringComparatorEq() {
+
+ Patient p= new Patient();
+ p.addName().setFamily("Smith").addGiven("John");
+ p.setActive(true);
+ String id1 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
+
+ p = new Patient();
+ p.addName().setFamily("Jones").addGiven("Frank");
+ p.setActive(false);
+ String id2 = myPatientDao.create(p).getId().toUnqualifiedVersionless().getValue();
+
+ SearchParameterMap map;
+ List
May 30, 2019 - HAPI FHIR 3.8.0 (Hippo) Released - The next release of HAPI has now been uploaded to the Maven repos and