From 7efcf879c1b9bf40125699196773d1fbf21c5f5f Mon Sep 17 00:00:00 2001 From: Jermy Li Date: Wed, 4 Jan 2023 23:18:55 +0800 Subject: [PATCH] fix: check uncommit due gremlin partition test silently fails (#2065) --- .../apache/hugegraph/backend/tx/GraphTransaction.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java index 3300d3777..4cf3ea108 100644 --- a/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java +++ b/hugegraph-core/src/main/java/org/apache/hugegraph/backend/tx/GraphTransaction.java @@ -542,12 +542,19 @@ public class GraphTransaction extends IndexableTransaction { @Override public Number queryNumber(Query query) { + boolean isConditionQuery = query instanceof ConditionQuery; boolean hasUpdate = this.hasUpdate(); Aggregate aggregate = query.aggregateNotNull(); + // TODO: we can concat index-query results and tx uncommitted records. + if (hasUpdate) { + E.checkArgument(!isConditionQuery, + "It's not allowed to query by index when " + + "there are uncommitted records."); + } + QueryList queries = this.optimizeQueries(query, q -> { boolean isIndexQuery = q instanceof IdQuery; - boolean isConditionQuery = query instanceof ConditionQuery; assert isIndexQuery || isConditionQuery || q == query; // Need to fallback if there are uncommitted records boolean fallback = hasUpdate;