Skip to content

Commit

Permalink
fix: corrected query with content of nested json documents to use emb…
Browse files Browse the repository at this point in the history
…edded class
  • Loading branch information
tglman committed Feb 12, 2024
1 parent d367b8d commit 2a88158
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Object execute(OIdentifiable iCurrentRecord, OCommandContext ctx) {
return arrayConcatExpression.execute(iCurrentRecord, ctx);
}
if (json != null) {
return json.toMap(iCurrentRecord, ctx);
return json.toObjectDetermineType(iCurrentRecord, ctx);
}
if (booleanValue != null) {
return booleanValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.db.record.OIdentifiable;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.orientechnologies.orient.core.record.OElement;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.record.impl.ODocumentHelper;
import com.orientechnologies.orient.core.serialization.serializer.record.string.OFieldTypesString;
import com.orientechnologies.orient.core.sql.executor.OResult;
import com.orientechnologies.orient.core.sql.executor.OResultInternal;
import com.orientechnologies.orient.core.sql.executor.OUpdatableResult;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
Expand Down Expand Up @@ -134,6 +136,20 @@ public Object toObjectDetermineType(OResult source, OCommandContext ctx) {
}
}

public Object toObjectDetermineType(OIdentifiable source, OCommandContext ctx) {
String className = getClassNameForDocument(ctx);
String type = getTypeForDocument(ctx);
if (className != null || (type != null && "d".equalsIgnoreCase(type))) {
OUpdatableResult element = null;
if (source != null) {
element = new OUpdatableResult((OElement) ctx.getDatabase().load(source.getIdentity()));
}
return toDocument(element, ctx, className);
} else {
return toMap(source, ctx);
}
}

public Map<String, Object> toMap(OIdentifiable source, OCommandContext ctx) {
Map<String, Object> doc = new LinkedHashMap<String, Object>();
for (OJsonItem item : items) {
Expand Down

0 comments on commit 2a88158

Please sign in to comment.