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: Noop in case there is no change in autocommit value for setAutocommit() method #2662

Merged
merged 5 commits into from Oct 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -401,6 +401,9 @@ public boolean isClosed() {

@Override
public void setAutocommit(boolean autocommit) {
if (isAutocommit() == autocommit) {
olavloite marked this conversation as resolved.
Show resolved Hide resolved
return;
}
ConnectionPreconditions.checkState(!isClosed(), CLOSED_ERROR_MSG);
ConnectionPreconditions.checkState(!isBatchActive(), "Cannot set autocommit while in a batch");
ConnectionPreconditions.checkState(
Expand Down
Expand Up @@ -412,6 +412,22 @@ public void testExecuteSetAutocommitOff() {
}
}

@Test
public void testExecuteAutocommitNoop() {
try (ConnectionImpl subject =
createConnection(
ConnectionOptions.newBuilder()
.setCredentials(NoCredentials.getInstance())
.setUri(URI)
.build())) {
assertThat(subject.isAutocommit(), is(true));
olavloite marked this conversation as resolved.
Show resolved Hide resolved

StatementResult res = subject.execute(Statement.of("set autocommit = true"));
assertThat(res.getResultType(), is(equalTo(ResultType.NO_RESULT)));
assertThat(subject.isAutocommit(), is(true));
}
}

@Test
public void testExecuteGetAutocommit() {
try (ConnectionImpl subject =
Expand Down