Fix bug when in-memory matcher compares long id to string id

This commit is contained in:
Ken Stevens 2019-08-06 15:17:09 -04:00
parent 13a83567ae
commit c11d719957
4 changed files with 12 additions and 12 deletions

View File

@ -645,16 +645,8 @@ public class IdDt extends UriDt implements /*IPrimitiveDatatype<String>, */IIdTy
return new IdDt(value + '/' + Constants.PARAM_HISTORY + '/' + theVersion);
}
private static boolean isValidLong(String id) {
if (StringUtils.isBlank(id)) {
return false;
}
for (int i = 0; i < id.length(); i++) {
if (Character.isDigit(id.charAt(i)) == false) {
return false;
}
}
return true;
public static boolean isValidLong(String id) {
return StringUtils.isNumeric(id);
}
/**

View File

@ -19,6 +19,7 @@ package ca.uhn.fhir.rest.param;
* limitations under the License.
* #L%
*/
import static ca.uhn.fhir.model.primitive.IdDt.isValidLong;
import static org.apache.commons.lang3.StringUtils.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
@ -280,4 +281,8 @@ public class ReferenceParam extends BaseParam /*implements IQueryParameterType*/
retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext));
return retVal;
}
public boolean isIdPartValidLong() {
return isValidLong(getIdPart());
}
}

View File

@ -274,7 +274,11 @@ public final class ResourceIndexedSearchParams {
ResourceTable target = theResourceLink.getTargetResource();
IdDt idDt = target.getIdDt();
if (idDt.isIdPartValidLong()) {
return theReference.getIdPartAsLong().equals(idDt.getIdPartAsLong());
if (theReference.isIdPartValidLong()) {
return theReference.getIdPartAsLong().equals(idDt.getIdPartAsLong());
} else {
return false;
}
} else {
ForcedId forcedId = target.getForcedId();
if (forcedId != null) {

View File

@ -23,7 +23,6 @@ public class ResourceIndexedSearchParamsTest {
target.setResourceType("Organization");
target.setId(123L);
ResourceIndexedSearchParams params = new ResourceIndexedSearchParams(source);
ResourceLink link = new ResourceLink("organization", source, target, new Date());
params.getResourceLinks().add(link);