core/src/main/java/com/orientechnologies/orient/core/sql/executor/FetchFromIndexStep.java
private Object unboxOResult(Object value) {
    if (value instanceof List) {
      return ((List) value).stream().map(x -> unboxOResult(x)).collect(Collectors.toList());
    }
    if (value instanceof OResult) {
      if (((OResult) value).isElement()) {
        return ((OResult) value).getIdentity().orElse(null);
      }
      Set<String> props = ((OResult) value).getPropertyNames();
      if (props.size() == 1) {
        return ((OResult) value).getProperty(props.iterator().next());
      }
    }
    return value;
  }
private Object unboxOResult(Object value) {
    if (value instanceof List) {
      return ((List) value).stream().map(x -> unboxOResult(x)).collect(Collectors.toList());
    }
    if (value instanceof OResult) {
      if (((OResult) value).isElement()) {
        return ((OResult) value).getIdentity().orElse(null);
      }
      Set<String> props = ((OResult) value).getPropertyNames();
      if (props.size() == 1) {
        return ((OResult) value).getProperty(props.iterator().next());
      }
    }
    return value;
  }
this is for subqueries, when a OResult is found <ul> <li>if it's a projection with a single column, the value is returned</li>
<li>if it's a document, the RID is returned</li> </ul>

@param value

@return