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: iterate over async result set in sync #416

Merged
merged 1 commit into from Sep 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -559,7 +559,7 @@ public boolean next() throws SpannerException {
this.state = State.SYNC;
}
boolean res = delegateResultSet.next();
currentRow = delegateResultSet.getCurrentRowAsStruct();
currentRow = res ? delegateResultSet.getCurrentRowAsStruct() : null;
return res;
}

Expand Down
Expand Up @@ -225,6 +225,19 @@ public CallbackResponse cursorReady(AsyncResultSet resultSet) {
assertThat(rowCount.get()).isEqualTo(1);
}

@Test
public void singleUseAsyncWithoutCallback() throws Exception {
DatabaseClient client =
spanner.getDatabaseClient(DatabaseId.of(TEST_PROJECT, TEST_INSTANCE, TEST_DATABASE));
int rowCount = 0;
try (AsyncResultSet rs = client.singleUse().executeQueryAsync(SELECT1)) {
while (rs.next()) {
rowCount++;
}
}
assertThat(rowCount).isEqualTo(1);
}

@Test
public void singleUseBound() {
DatabaseClient client =
Expand Down