66import static java .util .Objects .isNull ;
77import static java .util .stream .Collectors .joining ;
88import static java .util .stream .Collectors .toUnmodifiableList ;
9+ import static org .hypertrace .core .documentstore .expression .operators .RelationalOperator .EQ ;
910import static org .hypertrace .core .documentstore .expression .operators .RelationalOperator .IN ;
1011import static org .hypertrace .core .documentstore .model .options .ReturnDocumentType .NONE ;
1112import static org .hypertrace .entity .data .service .v1 .AttributeValue .VALUE_LIST_FIELD_NUMBER ;
4546import org .hypertrace .core .documentstore .SingleValueKey ;
4647import org .hypertrace .core .documentstore .expression .impl .ConstantExpression ;
4748import org .hypertrace .core .documentstore .expression .impl .IdentifierExpression ;
49+ import org .hypertrace .core .documentstore .expression .impl .LogicalExpression ;
4850import org .hypertrace .core .documentstore .expression .impl .RelationalExpression ;
4951import org .hypertrace .core .documentstore .model .options .UpdateOptions ;
5052import 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