Skip to content

Commit 0cf60fa

Browse files
committed
[PostgreSQL] Fix failure to query when database is empty
1 parent 27c4f51 commit 0cf60fa

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

src/renderer/app/pages/management/metadata/metadata.component.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { NzContextMenuService, NzDropdownMenuComponent } from 'ng-zorro-antd/dro
1313
import { NzMessageService } from 'ng-zorro-antd/message';
1414
import { NzFormatEmitEvent } from 'ng-zorro-antd/tree';
1515
import { DatabaseEnum } from "@renderer/enum/database.enum";
16+
import { StringUtils } from "@renderer/utils/string.utils";
1617

1718
@Component({
1819
selector: 'app-management-metadata',
@@ -187,9 +188,13 @@ export class MetadataComponent extends BaseComponent implements OnInit {
187188
const dataSource = await this.dataSourceService.getByAliasAsync(this.rootNode.value);
188189
this.rootNode['sourceType'] = dataSource.type;
189190
request.config = dataSource;
191+
190192
if (dataSource.type === DatabaseEnum.postgresql) {
191-
request.config.database = this.selectDatabase;
193+
if (StringUtils.isNotEmpty(this.selectDatabase)) {
194+
request.config.database = this.selectDatabase;
195+
}
192196
}
197+
193198
if (dataSource.type === DatabaseEnum.trino || dataSource.type === DatabaseEnum.presto) {
194199
this.items = [];
195200
this.loading.button = false;
@@ -222,7 +227,9 @@ export class MetadataComponent extends BaseComponent implements OnInit {
222227
request.config = await this.dataSourceService.getByAliasAsync(this.rootNode.value);
223228

224229
if (request.config.type === DatabaseEnum.postgresql) {
225-
request.config.database = this.selectDatabase;
230+
if (StringUtils.isNotEmpty(this.selectDatabase)) {
231+
request.config.database = this.selectDatabase;
232+
}
226233
originNode.database = this.selectTable;
227234
}
228235

0 commit comments

Comments
 (0)