Files
bun.sh/test/js
Claude Bot fde24342d9 Improve PostgreSQL unix socket path handling for custom socket files
Enhances the path handling logic in the PostgreSQL adapter to better support
custom socket file paths while maintaining backward compatibility.

## Current behavior (main branch)
The original code always appends `/.s.PGSQL.${port}` to any path:
```typescript
if (path && path?.indexOf("/.s.PGSQL.") === -1) {
  path = `${path}/.s.PGSQL.${port}`;
}
```

Examples:
- `"/var/run/postgresql"` → `"/var/run/postgresql/.s.PGSQL.5432"`  (correct)
- `"/tmp/postgres.sock"` → `"/tmp/postgres.sock/.s.PGSQL.5432"`  (invalid path)

## Improved behavior
Now distinguishes between directory and file paths:
```typescript
if (path && path.indexOf("/.s.PGSQL.") === -1) {
  if (path.endsWith("/") || (!path.includes(".") && !path.includes("sock"))) {
    path = `${path}/.s.PGSQL.${port}`;
  }
  // Otherwise use path as-is
}
```

Examples:
- `"/var/run/postgresql"` → `"/var/run/postgresql/.s.PGSQL.5432"`  (unchanged)
- `"/tmp/postgres.sock"` → `"/tmp/postgres.sock"`  (now correct)
- `"/var/run/postgresql/"` → `"/var/run/postgresql//.s.PGSQL.5432"` 

## Impact
- **Maintains compatibility**: Standard directory paths work exactly as before
- **Enables custom sockets**: Users can now specify complete socket file paths
- **Related to #20729**: Improves path handling though the connection issue may have other causes

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-22 05:05:13 +00:00
..