googleapis/java-datastore

Cloud Datastore Java SDK - parent keys are created without the correct database ID

nzhenry opened this issue · 0 comments

Environment details

Java version: 17
SDK version: 2.19.4-SNAPSHOT

Steps to reproduce

  1. Create a key with a parent and a non-default database ID
  2. Compare the database ID of the key to the database ID of the parent
  3. Observe the values are different. They should be the same.

Code example

Key entityKey = DatastoreOptions.newBuilder()
        .setDatabaseId("my-database-id")
        .build()
        .getService()
        .newKeyFactory()
        .setKind("EntityKind")
        .addAncestor(PathElement.of("ParentKind", 1L))
        .newKey(2L);
System.out.printf("Entity database ID: %s%n", entityKey.getDatabaseId());
System.out.printf("Parent database ID: %s%n", entityKey.getParent().getDatabaseId());