From 86e217fb78adb7350c10be56dfe4f6350153bd23 Mon Sep 17 00:00:00 2001 From: Michael Lehenbauer Date: Wed, 16 Jan 2019 17:26:58 -0800 Subject: [PATCH] Firestore: Include a trailing /documents on root resource paths This is required for v1 and accepted in v1beta1. Port of https://github.com/googleapis/nodejs-firestore/pull/516/commits/52c7381bc4f964c0ca0925f19c5192bf4a3e63c6 --- .../main/java/com/google/cloud/firestore/FirestoreImpl.java | 2 +- .../src/main/java/com/google/cloud/firestore/ResourcePath.java | 3 +-- .../java/com/google/cloud/firestore/LocalFirestoreHelper.java | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java index 54d479fbda22..726cd4f6f605 100644 --- a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java +++ b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/FirestoreImpl.java @@ -426,7 +426,7 @@ boolean areTimestampsInSnapshotsEnabled() { /** Returns the name of the Firestore project associated with this client. */ String getDatabaseName() { - return databasePath.toString(); + return databasePath.getDatabaseName().toString(); } /** Returns the underlying RPC client. */ diff --git a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java index 0633d938866a..6f6be76a9829 100644 --- a/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java +++ b/google-cloud-clients/google-cloud-firestore/src/main/java/com/google/cloud/firestore/ResourcePath.java @@ -127,9 +127,8 @@ String getPath() { */ String getName() { String path = getPath(); - if (path.isEmpty()) { - return getDatabaseName().toString(); + return getDatabaseName() + "/documents"; } else { return getDatabaseName() + "/documents/" + getPath(); } diff --git a/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java b/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java index 8876fa83cf64..fe740c7cc476 100644 --- a/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java +++ b/google-cloud-clients/google-cloud-firestore/src/test/java/com/google/cloud/firestore/LocalFirestoreHelper.java @@ -435,7 +435,7 @@ public static RunQueryRequest query(StructuredQuery... query) { public static RunQueryRequest query( @Nullable ByteString transactionId, StructuredQuery... query) { RunQueryRequest.Builder request = RunQueryRequest.newBuilder(); - request.setParent(LocalFirestoreHelper.DATABASE_NAME); + request.setParent(LocalFirestoreHelper.DATABASE_NAME + "/documents"); StructuredQuery.Builder structuredQuery = request.getStructuredQueryBuilder(); structuredQuery.addFrom( StructuredQuery.CollectionSelector.newBuilder().setCollectionId("coll"));