Skip to content

Commit

Permalink
fix: add missing null check
Browse files Browse the repository at this point in the history
  • Loading branch information
waukin committed Jan 21, 2025
1 parent 090709b commit 75af11f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ public void output(Catalog[] catalogs) {
static final class SchemaPlainFormat implements OutputFormat<Schema> {
@Override
public void output(Schema schema) {
System.out.println(schema.name() + "," + schema.comment());
if (schema == null) {
System.out.println("No schemas exist.");
} else {
System.out.println(schema.name() + "," + schema.comment());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,15 @@ public void output(Catalog[] catalogs) {
static final class SchemaTableFormat implements OutputFormat<Schema> {
@Override
public void output(Schema schema) {
List<String> headers = Arrays.asList("schema", "comment");
List<List<String>> rows = new ArrayList<>();
rows.add(Arrays.asList(schema.name(), schema.comment() + ""));
TableFormatImpl tableFormat = new TableFormatImpl();
tableFormat.print(headers, rows);
if (schema == null) {
System.out.println("No schemas exist.");
} else {
List<String> headers = Arrays.asList("schema", "comment");
List<List<String>> rows = new ArrayList<>();
rows.add(Arrays.asList(schema.name(), schema.comment() + ""));
TableFormatImpl tableFormat = new TableFormatImpl();
tableFormat.print(headers, rows);
}
}
}

Expand Down

0 comments on commit 75af11f

Please sign in to comment.