Skip to content

feat: [WIP] Support sql to mutations #1067

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

Draft
wants to merge 3 commits into
base: read-committed
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions clirr-ignored-differences.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,14 @@
<className>com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection</className>
<method>com.google.cloud.spanner.Dialect getDialect()</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection</className>
<method>void setConvertDmlToMutations(boolean)</method>
</difference>
<difference>
<differenceType>7012</differenceType>
<className>com/google/cloud/spanner/jdbc/CloudSpannerJdbcConnection</className>
<method>boolean isConvertDmlToMutations()</method>
</difference>
</differences>
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,11 @@ default String getStatementTag() throws SQLException {
*/
void bufferedWrite(Mutation mutation) throws SQLException;

boolean isConvertDmlToMutations() throws SQLException;

/** Instructs the JDBC connection to automatically convert DML statements to mutations. */
void setConvertDmlToMutations(boolean convert) throws SQLException;

/**
* Buffers the given mutations locally on the current transaction of this {@link Connection}. The
* mutations will be written to the database at the next call to {@link Connection#commit()}. The
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/google/cloud/spanner/jdbc/JdbcConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,21 @@ public void bufferedWrite(Iterable<Mutation> mutations) throws SQLException {
}
}

public boolean isConvertDmlToMutations() throws SQLException {
checkClosed();
return getSpannerConnection().isConvertDmlToMutations();
}

@Override
public void setConvertDmlToMutations(boolean convert) throws SQLException {
checkClosed();
try {
getSpannerConnection().setConvertDmlToMutations(convert);
} catch (SpannerException e) {
throw JdbcSqlExceptionFactory.of(e);
}
}

@SuppressWarnings("deprecation")
private static final class JdbcToSpannerTransactionRetryListener
implements com.google.cloud.spanner.connection.TransactionRetryListener {
Expand Down