Skip to content
Merged
Show file tree
Hide file tree
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
13 changes: 9 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ jobs:

- name: Upload integration test results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: integration-test-results-pg${{ matrix.postgres-version }}
path: test-results/
Expand Down Expand Up @@ -127,8 +127,13 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install PostgreSQL client
run: |
sudo apt-get update
sudo apt-get install -y postgresql-client

- name: Start PostgreSQL test containers
run: docker-compose -f docker-compose.test.yml up -d
run: docker compose -f docker-compose.test.yml up -d

- name: Wait for PostgreSQL services
run: |
Expand Down Expand Up @@ -163,7 +168,7 @@ jobs:

- name: Cleanup Docker containers
if: always()
run: docker-compose -f docker-compose.test.yml down
run: docker compose -f docker-compose.test.yml down

lint-and-format:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -192,7 +197,7 @@ jobs:
- uses: actions/checkout@v4

- name: Download all coverage reports
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
path: coverage-reports

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ dist
pat-open-vsx
.nyc_output/
coverage/
out_test/
58 changes: 32 additions & 26 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"type": "npm",
"script": "compile",
"problemMatcher": "$tsc",
"presentation": {
"reveal": "never"
},
"group": "build"
}
]
}
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "esbuild",
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": "build"
},
{
"type": "npm",
"script": "compile",
"problemMatcher": "$tsc",
"presentation": {
"reveal": "never"
},
"group": "build"
}
]
}
17 changes: 9 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2072,14 +2072,15 @@
"watch": "tsc -watch -p ./",
"esbuild": "npm run esbuild-base -- --sourcemap && npm run esbuild-renderer -- --sourcemap",
"esbuild-watch": "npm run esbuild-base -- --sourcemap --watch & npm run esbuild-renderer -- --sourcemap --watch",
"test": "npm run compile && ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/unit/**/*.test.ts'",
"test:unit": "npm run compile && ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/unit/**/*.test.ts'",
"test:integration": "npm run compile && ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/integration/**/*.test.ts'",
"test:renderer": "npm run compile && ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/unit/RendererComponents.test.ts'",
"test:renderer:coverage": "npm run compile && nyc ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/unit/RendererComponents.test.ts'",
"test:versions": "npm run compile && ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/integration/ConnectionLifecycle.test.ts'",
"test:all": "npm run compile && ts-mocha -p src/test/tsconfig.json -r src/test/setup.ts 'src/test/**/*.test.ts'",
"coverage": "npm run compile && nyc npm run test:all",
"test": "npm run compile && mocha --loader ./node_modules/ts-node/esm/transpile-only.mjs -r tsconfig-paths/register -r src/test/setup.ts 'src/test/unit/**/*.test.ts'",
"test:unit": "npm run compile && ts-mocha -p src/test/tsconfig.json -r tsconfig-paths/register -r src/test/setup.ts 'src/test/unit/**/*.test.ts'",
"test:integration": "npm run compile && ts-mocha -p src/test/tsconfig.json -r tsconfig-paths/register -r src/test/setup.ts 'src/test/integration/**/*.test.ts'",
"test:renderer": "npm run compile && ts-mocha -p src/test/tsconfig.json -r tsconfig-paths/register -r src/test/setup.ts 'src/test/unit/RendererComponents.test.ts'",
"test:renderer:coverage": "npm run compile && nyc ts-mocha -p src/test/tsconfig.json -r tsconfig-paths/register -r src/test/setup.ts 'src/test/unit/RendererComponents.test.ts'",
"test:versions": "npm run compile && ts-mocha -p src/test/tsconfig.json -r tsconfig-paths/register -r src/test/setup.ts 'src/test/integration/ConnectionLifecycle.test.ts'",
"test:all": "npm run compile && ts-mocha -p src/test/tsconfig.json -r ts-node/register -r tsconfig-paths/register -r src/test/setup.ts 'src/test/**/*.test.ts'",
"build-tests": "tsc -p src/test/tsconfig.json --outDir out_test",
"coverage": "npm run compile && npm run build-tests && nyc mocha -r tsconfig-paths/register -r ./out_test/setup.js 'out_test/**/*.test.js'",
"coverage:report": "nyc report --reporter=html --reporter=text"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/commands/aiAssist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ Then provide the SQL query. Remember: NO markdown formatting, just the raw SQL (
const AiTaskSelector = {
tasks: [
// Custom - Always First
{ label: '$(edit) Custom Instruction', description: 'Enter your own instruction', detail: 'Tell the AI exactly what you want to do with this query', kind: vscode.QuickPickItemKind.Default },
{ label: '$(edit) Custom Instruction', description: 'Enter your own instruction', detail: 'Tell the AI exactly what you want to do with this query' },

// Separator
{ label: '', kind: vscode.QuickPickItemKind.Separator },
Expand Down
16 changes: 13 additions & 3 deletions src/commands/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PostgresMetadata } from '../common/types';
import { DatabaseTreeItem, DatabaseTreeProvider } from '../providers/DatabaseTreeProvider';
import { ConnectionManager } from '../services/ConnectionManager';
import { SecretStorageService } from '../services/SecretStorageService';
import { resolvePgPassPassword } from '../utils/pgPassUtils';
import { ErrorHandlers } from './helper';

/**
Expand Down Expand Up @@ -73,17 +74,26 @@ export function validateCategoryItem(item: DatabaseTreeItem): asserts item is Da
/**
* getConnectionWithPassword - Retrieves the connection details and password for the specified connection ID.
*/
export async function getConnectionWithPassword(connectionId: string): Promise<any> {
export async function getConnectionWithPassword(connectionId: string, databaseName?: string): Promise<any> {
const connections = vscode.workspace.getConfiguration().get<any[]>('postgresExplorer.connections') || [];
const connection = connections.find(c => c.id === connectionId);

if (!connection) {
throw new Error('Connection not found');
}

const password = await SecretStorageService.getInstance().getPassword(connectionId);
let password = await SecretStorageService.getInstance().getPassword(connectionId);
if (!password && connection.username) {
password = resolvePgPassPassword(
connection.host,
connection.port,
databaseName || connection.database || 'postgres',
connection.username
);
}

if (!password) {
throw new Error('Password not found in secure storage');
throw new Error('Password not found in secure storage or .pgpass');
}

return {
Expand Down
6 changes: 3 additions & 3 deletions src/commands/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ DROP DATABASE IF EXISTS "${item.label}";`)

export async function cmdBackupDatabase(item: DatabaseTreeItem, context: vscode.ExtensionContext) {
try {
const connectionConfig = await getConnectionWithPassword(item.connectionId!);
const connectionConfig = await getConnectionWithPassword(item.connectionId!, item.databaseName);

// 1. Prompt for save location
const uri = await vscode.window.showSaveDialog({
Expand Down Expand Up @@ -599,7 +599,7 @@ export async function cmdBackupDatabase(item: DatabaseTreeItem, context: vscode.

export async function cmdRestoreDatabase(item: DatabaseTreeItem, context: vscode.ExtensionContext) {
try {
const connectionConfig = await getConnectionWithPassword(item.connectionId!);
const connectionConfig = await getConnectionWithPassword(item.connectionId!, item.databaseName);

// 1. Prompt for source file
const uris = await vscode.window.showOpenDialog({
Expand Down Expand Up @@ -780,7 +780,7 @@ SELECT 1;`)

export async function cmdPsqlTool(item: DatabaseTreeItem, context: vscode.ExtensionContext) {
try {
const connectionConfig = await getConnectionWithPassword(item.connectionId!);
const connectionConfig = await getConnectionWithPassword(item.connectionId!, item.databaseName);

const terminal = vscode.window.createTerminal(`PSQL: ${item.label}`);
terminal.show();
Expand Down
2 changes: 1 addition & 1 deletion src/commands/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export { validateItem, validateCategoryItem, validateRoleItem };
/** Get database connection and metadata for tree item operations */
export async function getDatabaseConnection(item: DatabaseTreeItem, validateFn: (item: DatabaseTreeItem) => void = validateItem) {
validateFn(item);
const connection = await getConnectionWithPassword(item.connectionId!);
const connection = await getConnectionWithPassword(item.connectionId!, item.databaseName);
const client = await ConnectionManager.getInstance().getPooledClient({
id: connection.id,
host: connection.host,
Expand Down
Loading
Loading