Skip to content

Commit

Permalink
fix: make sure to correctly evaluate return statemens in insert and u…
Browse files Browse the repository at this point in the history
…pdate statements
  • Loading branch information
tglman committed Oct 30, 2024
1 parent 6214fab commit 57f03b5
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.orientechnologies.common.concur.OTimeoutException;
import com.orientechnologies.orient.core.command.OCommandContext;
import com.orientechnologies.orient.core.id.ORID;
import com.orientechnologies.orient.core.record.ORecord;
import com.orientechnologies.orient.core.record.impl.ODocument;
import com.orientechnologies.orient.core.sql.executor.resultset.OFilterResultSet;
Expand Down Expand Up @@ -46,8 +47,16 @@ private OResult filterMap(OResult result) {
return new OUpdatableResult((ODocument) element);
}
return result;
} else {
Object id = result.getProperty("@rid");
if (id instanceof ORID) {
ORecord element = ctx.getDatabase().load((ORID) id);
if (element != null && element instanceof ODocument) {
return new OUpdatableResult((ODocument) element);
}
}
return null;
}
return null;
} finally {
cost = (System.nanoTime() - begin);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -532,6 +532,14 @@ public boolean isIndexChain(OCommandContext ctx, OClass clazz) {
}
return false;
}

public boolean isSelf() {
if (identifier != null && modifier == null) {
return identifier.isSelf();
} else {
return false;
}
}
}

/* JavaCC - OriginalChecksum=71b3e2d1b65c923dc7cfe11f9f449d2b (do not edit this line) */
Original file line number Diff line number Diff line change
Expand Up @@ -407,5 +407,13 @@ public boolean isIndexChain(OCommandContext ctx, OClass clazz) {
}
return false;
}

public boolean isSelf() {
if (levelZero != null) {
return levelZero.isSelf();
} else {
return false;
}
}
}
/* JavaCC - OriginalChecksum=ed89af10d8be41a83428c5608a4834f6 (do not edit this line) */
Original file line number Diff line number Diff line change
Expand Up @@ -705,5 +705,13 @@ public boolean isFunctionAll() {
public void setNull(boolean isNull) {
this.isNull = isNull;
}

public boolean isSelf() {
if (mathExpression != null) {
return mathExpression.isSelf();
} else {
return false;
}
}
}
/* JavaCC - OriginalChecksum=9c860224b121acdc89522ae97010be01 (do not edit this line) */
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,10 @@ public void extractSubQueries(SubQueryCollector collector) {
}
}

public boolean isSelf() {
return Boolean.TRUE.equals(self);
}

public boolean isCacheable() {
if (functionCall != null) {
return functionCall.isCacheable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1276,5 +1276,9 @@ private String serializeOperator(Operator x) {
private Operator deserializeOperator(String x) {
return Operator.valueOf(x);
}

public boolean isSelf() {
return false;
}
}
/* JavaCC - OriginalChecksum=c255bea24e12493e1005ba2a4d1dbb9d (do not edit this line) */
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ public OResult calculateSingle(OCommandContext iContext, OResult iRecord) {
}

if (items.size() == 0
|| (items.size() == 1 && items.get(0).isAll()) && items.get(0).nestedProjection == null) {
|| (items.size() == 1
&& (items.get(0).isAll() || items.get(0).isSelf())
&& items.get(0).nestedProjection == null)) {
return iRecord;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,14 @@ public void toString(Map<Object, Object> params, StringBuilder builder) {
}
}

public boolean isSelf() {
if (expression != null) {
return expression.isSelf();
} else {
return false;
}
}

public void toGenericStatement(StringBuilder builder) {
if (all) {
builder.append("*");
Expand Down

0 comments on commit 57f03b5

Please sign in to comment.