Skip to content

Commit

Permalink
fix(datastore): add ignoreNonExistingTable option for scan table (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
jialeicui authored Sep 8, 2022
1 parent 63fe939 commit 3c7351a
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public ResponseEntity<ResponseMessage<RecordListVo>> scanTable(ScanTableRequest
.limit(request.getLimit())
.keepNone(request.isKeepNone())
.rawResult(request.isRawResult())
.ignoreNonExistingTable(request.isIgnoreNonExistingTable())
.build());
return ResponseEntity.ok(Code.success.asResponse(RecordListVo.builder()
.columnTypes(recordList.getColumnTypeMap())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@ public class ScanTableRequest {
private int limit = -1;
private boolean keepNone;
private boolean rawResult;
private boolean ignoreNonExistingTable;
}
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,27 @@ public void testNullTableName() {
"");
}

@Test
public void testTableNotExists() {
this.req.setTableName("table not exists");
assertThrows(SwValidationException.class,
() -> DataStoreControllerTest.this.controller.queryTable(this.req),
"");
}

@Test
public void testTableNotExistsIgnore() {
this.req.setTableName("table not exists");
this.req.setIgnoreNonExistingTable(true);

var resp = DataStoreControllerTest.this.controller.queryTable(this.req);
assertThat("test", resp.getStatusCode().is2xxSuccessful(), is(true));
assertThat("test",
Objects.requireNonNull(resp.getBody()).getData().getColumnTypes().isEmpty());
assertThat("test",
Objects.requireNonNull(resp.getBody()).getData().getRecords().isEmpty());
}

@Test
public void testNullColumnName() {
this.req.getColumns().get(0).setColumnName(null);
Expand Down Expand Up @@ -1158,6 +1179,15 @@ public void testInvalidTableName() {
"");
}

@Test
public void testTableNotExistsIgnore() {
this.req.getTables().get(0).setTableName("invalid");
this.req.setIgnoreNonExistingTable(true);

var resp = DataStoreControllerTest.this.controller.scanTable(this.req);
assertThat("test", resp.getStatusCode().is2xxSuccessful(), is(true));
}

@Test
public void testNullColumn() {
this.req.getTables().get(0).setColumns(
Expand Down

0 comments on commit 3c7351a

Please sign in to comment.