Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: deprecate databaseId on datastore-v1-proto-client DatastoreOptions #1190

Merged
merged 4 commits into from
Sep 14, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
*/
public class DatastoreOptions {
private final String projectId;
private final String databaseId;

@Deprecated private final String databaseId;

private final String projectEndpoint;
private final String host;
private final String localHost;
Expand Down Expand Up @@ -75,7 +77,9 @@ public static class Builder {
"Can set at most one of project endpoint, host, and local host.";

private String projectId;
private String databaseId;

@Deprecated private String databaseId;

private String projectEndpoint;
private String host;
private String localHost;
Expand Down Expand Up @@ -107,8 +111,19 @@ public Builder projectId(String projectId) {
return this;
}

/** Sets the database ID used to access Cloud Datastore. */
/**
* This field is ignored and will be removed in a future release. Please set the database id on
* the request itself. For example:
*
* <pre>{@code
* CommitRequest.newBuilder()
* .setDatabaseId("my-database-id")
* ....
* .build();
* }</pre>
*/
@BetaApi
@Deprecated
public Builder databaseId(String databaseId) {
this.databaseId = databaseId;
return this;
Expand Down Expand Up @@ -188,7 +203,19 @@ public String getProjectId() {
return projectId;
}

/**
* This field is ignored and will be removed in a future release. Please set the database id on
* the request itself. For example:
*
* <pre>{@code
* CommitRequest.newBuilder()
* .setDatabaseId("my-database-id")
* ....
* .build();
* }</pre>
*/
@BetaApi
@Deprecated
public String getDatabaseId() {
return databaseId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,8 @@ public void create_LocalHost() {
@Test
public void setDatabaseId() {
DatastoreOptions options =
new DatastoreOptions.Builder()
.projectId(PROJECT_ID)
.databaseId("test-db")
.localHost("localhost:8080")
.build();
new DatastoreOptions.Builder().projectId(PROJECT_ID).localHost("localhost:8080").build();
kolea2 marked this conversation as resolved.
Show resolved Hide resolved
assertThat(options.getProjectId()).isEqualTo(PROJECT_ID);
assertThat(options.getDatabaseId()).isEqualTo("test-db");
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public HttpDatastoreRpc(DatastoreOptions options) {
com.google.datastore.v1.client.DatastoreOptions.Builder clientBuilder =
new com.google.datastore.v1.client.DatastoreOptions.Builder()
.projectId(options.getProjectId())
.databaseId(options.getDatabaseId())
.initializer(getHttpRequestInitializer(options, httpTransportOptions))
.transport(transport);
String normalizedHost = options.getHost() != null ? options.getHost().toLowerCase() : "";
Expand Down