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

feat: support CREATE DATABASE in Connection API #1845

Merged
merged 3 commits into from
Apr 28, 2022
Merged

Conversation

olavloite
Copy link
Collaborator

@olavloite olavloite commented Apr 21, 2022

Adds support for the CREATE DATABASE statement in the Connection API.
The statement can only be used with a SingleUseTransaction (i.e. auto
commit mode). It is not supported in DDL batches. The database that is
created will have the same dialect as the current database that the user
is connected to.

Fixes #1844

Towards b/229420558

Adds support for the CREATE DATABASE statement in the Connection API.
The statement can only be used with a SingleUseTransaction (i.e. auto
commit mode). It is not supported in DDL batches. The database that is
created will have the same dialect as the current database that the user
is connected to.

Fixes #1884
@olavloite olavloite requested review from a team as code owners April 21, 2022 17:52
@product-auto-label product-auto-label bot added size: m Pull request size is medium. api: spanner Issues related to the googleapis/java-spanner API. labels Apr 21, 2022
Copy link
Contributor

@ansh0l ansh0l left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a query, please take a look

Iterable<String> statements)
throws SpannerException {
throw new UnsupportedOperationException("Unimplemented");
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We seem to be throwing SpannerException elsewhere with createDatabase in the interface. Why is it an UnsupportedOperationException("Unimplemented"); for this one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only to make this a non-breaking change. We add this when we add a new method to a public interface. This prevents compile errors for downstream users that might implement this interface in a test, as the method has a default implementation. See for example this example from the DatabaseClient where we did the same thing:

throw new UnsupportedOperationException("method should be overwritten");

Copy link
Contributor

@rajatbhatta rajatbhatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@olavloite olavloite merged commit 40110fe into main Apr 28, 2022
@olavloite olavloite deleted the pg-create-database branch April 28, 2022 12:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: spanner Issues related to the googleapis/java-spanner API. size: m Pull request size is medium.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

feat: Support CREATE DATABASE statements in the Connection API
4 participants