diff --git a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java index e66393b84..2ca9f2258 100644 --- a/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java +++ b/google-cloud-firestore/src/main/java/com/google/cloud/firestore/Query.java @@ -1151,13 +1151,7 @@ public Query startAt(@Nonnull DocumentSnapshot snapshot) { */ @Nonnull public Query startAt(Object... fieldValues) { - // TODO(b/296435819): Remove this warning message. - warningOnSingleDocumentReference(fieldValues); - - ImmutableList fieldOrders = - fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference - ? createImplicitOrderBy() - : options.getFieldOrders(); + ImmutableList fieldOrders = options.getFieldOrders(); Cursor cursor = createCursor(fieldOrders, fieldValues, true); Builder newOptions = options.toBuilder(); @@ -1246,13 +1240,7 @@ public Query startAfter(@Nonnull DocumentSnapshot snapshot) { * @return The created Query. */ public Query startAfter(Object... fieldValues) { - // TODO(b/296435819): Remove this warning message. - warningOnSingleDocumentReference(fieldValues); - - ImmutableList fieldOrders = - fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference - ? createImplicitOrderBy() - : options.getFieldOrders(); + ImmutableList fieldOrders = options.getFieldOrders(); Cursor cursor = createCursor(fieldOrders, fieldValues, false); Builder newOptions = options.toBuilder(); @@ -1290,13 +1278,7 @@ public Query endBefore(@Nonnull DocumentSnapshot snapshot) { */ @Nonnull public Query endBefore(Object... fieldValues) { - // TODO(b/296435819): Remove this warning message. - warningOnSingleDocumentReference(fieldValues); - - ImmutableList fieldOrders = - fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference - ? createImplicitOrderBy() - : options.getFieldOrders(); + ImmutableList fieldOrders = options.getFieldOrders(); Cursor cursor = createCursor(fieldOrders, fieldValues, true); Builder newOptions = options.toBuilder(); @@ -1314,13 +1296,7 @@ public Query endBefore(Object... fieldValues) { */ @Nonnull public Query endAt(Object... fieldValues) { - // TODO(b/296435819): Remove this warning message. - warningOnSingleDocumentReference(fieldValues); - - ImmutableList fieldOrders = - fieldValues.length == 1 && fieldValues[0] instanceof DocumentReference - ? createImplicitOrderBy() - : options.getFieldOrders(); + ImmutableList fieldOrders = options.getFieldOrders(); Cursor cursor = createCursor(fieldOrders, fieldValues, false); Builder newOptions = options.toBuilder(); @@ -1329,16 +1305,6 @@ public Query endAt(Object... fieldValues) { return new Query(rpcContext, newOptions.build()); } - private void warningOnSingleDocumentReference(Object... fieldValues) { - if (options.getFieldOrders().isEmpty() - && fieldValues.length == 1 - && fieldValues[0] instanceof DocumentReference) { - LOGGER.warning( - "Warning: Passing DocumentReference into a cursor without orderBy clause is not an intended " - + "behavior. Please use DocumentSnapshot or add an explicit orderBy on document key field."); - } - } - /** * Creates and returns a new Query that ends at the provided document (inclusive). The end * position is relative to the order of the query. The document must contain all of the fields diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java index 280c6e02a..7380305e0 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/QueryTest.java @@ -599,23 +599,6 @@ public void withDocumentIdAndDocumentSnapshotCursor() { assertEquals(queryRequest, runQuery.getValue()); } - @Test - public void withDocumentReferenceCursor() { - doAnswer(queryResponse()) - .when(firestoreMock) - .streamRequest(runQuery.capture(), streamObserverCapture.capture(), any()); - - DocumentReference documentCursor = firestoreMock.document(DOCUMENT_PATH); - Value documentValue = reference(DOCUMENT_NAME); - - query.startAt(documentCursor).get(); - - RunQueryRequest queryRequest = - query(order("__name__", StructuredQuery.Direction.ASCENDING), startAt(documentValue, true)); - - assertEquals(queryRequest, runQuery.getValue()); - } - @Test public void withDocumentIdAndDocumentReferenceCursor() { doAnswer(queryResponse()) diff --git a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java index c84d00a19..aca4a9585 100644 --- a/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java +++ b/google-cloud-firestore/src/test/java/com/google/cloud/firestore/it/ITSystemTest.java @@ -875,7 +875,9 @@ public void startAfterAddsAnImplicitOrderByForDocumentReferences() throws Except doc1.set(map("foo", 1)).get(); doc2.set(map("foo", 1)).get(); - QuerySnapshot querySnapshot = randomColl.startAfter(doc1).get().get(); + DocumentSnapshot docSnap = doc1.get().get(); + + QuerySnapshot querySnapshot = randomColl.startAfter(docSnap).get().get(); assertEquals(1, querySnapshot.size()); Iterator documents = querySnapshot.iterator(); assertEquals(doc2, documents.next().getReference());