Skip to content

Commit 1415131

Browse files
authored
fix | fix the query for fetching the updated document (#284)
* fix | fix the query for fetching the updated document
1 parent d425959 commit 1415131

File tree

1 file changed

+17
-5
lines changed

1 file changed

+17
-5
lines changed

entity-service-impl/src/main/java/org/hypertrace/entity/query/service/EntityQueryServiceImpl.java

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import static java.util.Objects.isNull;
77
import static java.util.stream.Collectors.joining;
88
import static java.util.stream.Collectors.toUnmodifiableList;
9+
import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.EQ;
910
import static org.hypertrace.core.documentstore.expression.operators.RelationalOperator.IN;
1011
import static org.hypertrace.core.documentstore.model.options.ReturnDocumentType.NONE;
1112
import static org.hypertrace.entity.data.service.v1.AttributeValue.VALUE_LIST_FIELD_NUMBER;
@@ -45,6 +46,7 @@
4546
import org.hypertrace.core.documentstore.SingleValueKey;
4647
import org.hypertrace.core.documentstore.expression.impl.ConstantExpression;
4748
import org.hypertrace.core.documentstore.expression.impl.IdentifierExpression;
49+
import org.hypertrace.core.documentstore.expression.impl.LogicalExpression;
4850
import org.hypertrace.core.documentstore.expression.impl.RelationalExpression;
4951
import org.hypertrace.core.documentstore.model.options.UpdateOptions;
5052
import org.hypertrace.core.documentstore.model.subdoc.SubDocumentUpdate;
@@ -342,7 +344,10 @@ public void update(EntityUpdateRequest request, StreamObserver<ResultSetChunk> r
342344
// Finally, return the selections
343345
List<Document> documents =
344346
getProjectedDocuments(
345-
request.getEntityIdsList(), request.getSelectionList(), requestContext);
347+
maybeTenantId.get(),
348+
request.getEntityIdsList(),
349+
request.getSelectionList(),
350+
requestContext);
346351

347352
responseObserver.onNext(
348353
convertDocumentsToResultSetChunk(documents, request.getSelectionList()));
@@ -531,6 +536,7 @@ private JSONDocument convertToJsonDocument(LiteralConstant literalConstant) {
531536
}
532537

533538
private List<Document> getProjectedDocuments(
539+
final String tenantId,
534540
final Iterable<String> entityIds,
535541
final List<Expression> selectionList,
536542
final RequestContext requestContext)
@@ -546,10 +552,16 @@ private List<Document> getProjectedDocuments(
546552
final Filter filter =
547553
Filter.builder()
548554
.expression(
549-
RelationalExpression.of(
550-
IdentifierExpression.of(EntityServiceConstants.ENTITY_ID),
551-
IN,
552-
ConstantExpression.ofStrings(entityIdList)))
555+
LogicalExpression.and(
556+
List.of(
557+
RelationalExpression.of(
558+
IdentifierExpression.of(EntityServiceConstants.ENTITY_ID),
559+
IN,
560+
ConstantExpression.ofStrings(entityIdList)),
561+
RelationalExpression.of(
562+
IdentifierExpression.of(EntityServiceConstants.TENANT_ID),
563+
EQ,
564+
ConstantExpression.of(tenantId)))))
553565
.build();
554566

555567
final org.hypertrace.core.documentstore.query.Query query =

0 commit comments

Comments
 (0)