Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/commands/runQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,18 @@ export class runQueryCommand extends BaseCommand {

let connection = EditorState.connection;
if (!connection) {
vscode.window.showWarningMessage('No PostgreSQL Server or Database selected');
return;
// If we don't have a connection, then we need to get one, execute the 'vscode-postgres.selectConnection' command
// to get the user to select a connection
await vscode.commands.executeCommand('vscode-postgres.selectConnection');

// Try to get the connection again
connection = EditorState.connection;

// If the result is false, then the user cancelled the selection
if (!connection) {
vscode.window.showWarningMessage('No PostgreSQL Server or Database selected');
return;
}
}

let editor = vscode.window.activeTextEditor;
Expand Down