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

Execute the select connection command if user executes script without a connection #254

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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