Files
bun.sh/test/js/sql
Claude Bot 0e52d24bc4 refactor: Fix Bun.SQL options parsing to separate adapter detection and prevent env variable mixing
This commit refactors Bun.SQL's options parsing to fix issue #22147 and properly separate
PostgreSQL and MySQL environment variables based on the chosen adapter.

Key changes:
1. Separate adapter detection from options parsing
2. Only read environment variables appropriate for the selected adapter
3. Respect proper precedence: explicit options > adapter-specific env vars > generic env vars
4. Add support for unix:// protocol with explicit adapter specification
5. Validate adapter-protocol compatibility

Adapter detection logic:
- If adapter is explicitly set: use it
- If adapter is set to "mysql": use mysql adapter
- If adapter is set to "postgres"/"postgresql": use postgres adapter
- If protocol is mysql/mariadb/mysqls: use mysql adapter
- If protocol is postgres/postgresql: use postgres adapter
- If no protocol in URL: default to postgres adapter
- For unix:// protocol: require explicit adapter

Environment variable precedence by adapter:
- PostgreSQL: Only reads PGHOST, PGUSER, PGPASSWORD, etc. + generic USER/USERNAME
- MySQL: Only reads generic USER/USERNAME (no widely standardized MySQL env vars)
- SQLite: Only reads DATABASE_URL for SQLite URLs

This prevents mixing of PostgreSQL env vars when using MySQL adapter and vice versa,
while ensuring explicit connection options always take precedence over environment variables.

Fixes: #22147

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-30 12:07:23 -07:00
..
2025-08-19 23:15:53 -07:00
2025-05-08 18:51:32 -07:00
2025-05-08 18:51:32 -07:00
2025-08-01 22:41:05 -07:00
2025-08-19 23:15:53 -07:00