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); return new IdDt(value + '/' + Constants.PARAM_HISTORY + '/' + theVersion);
} }
private static boolean isValidLong(String id) { public static boolean isValidLong(String id) {
if (StringUtils.isBlank(id)) { return StringUtils.isNumeric(id);
return false;
}
for (int i = 0; i < id.length(); i++) {
if (Character.isDigit(id.charAt(i)) == false) {
return false;
}
}
return true;
} }
/** /**

View File

@ -19,6 +19,7 @@ package ca.uhn.fhir.rest.param;
* limitations under the License. * limitations under the License.
* #L% * #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.isBlank;
import static org.apache.commons.lang3.StringUtils.isNotBlank; 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)); retVal.setValueAsQueryToken(theContext, null, null, getValueAsQueryToken(theContext));
return retVal; return retVal;
} }
public boolean isIdPartValidLong() {
return isValidLong(getIdPart());
}
} }

View File

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

View File

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