Added tests to verify MySQL port defaulting behavior:
- MySQL URL without port defaults to 3306
- Explicit MySQL adapter defaults to 3306
- Both URL and explicit adapter scenarios work correctly
This documents the expected behavior and ensures proper port
handling across all MySQL connection scenarios.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
The previous implementation incorrectly checked if MYSQL_URL was a SQLite URL
using parseDefinitelySqliteUrl(). This fix properly checks the protocol of
environment URLs to determine the correct adapter:
- mysql://, mariadb://, mysqls:// → mysql adapter
- postgres://, postgresql:// → postgres adapter
- SQLite URLs (detected by parseDefinitelySqliteUrl) → sqlite adapter
Added tests to verify MYSQL_URL and POSTGRES_URL environment variables
correctly infer their respective adapters and that precedence is respected.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
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>
### What does this PR do?
handle Int24 to be numbers
### How did you verify your code works?
tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
add `lastInsertRowid` (matching SQLite)
add `affectedRows`
fix `mysql_native_password` deprecated authentication
fix AuthSwitch
Fixes:
https://github.com/oven-sh/bun/issues/22178#issuecomment-3228716080
### How did you verify your code works?
tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Fix handling BIT(1) and BIT(N) on binary protocol and text protocol, now
behavior is consistent
### How did you verify your code works?
Tests
### What does this PR do?
Change tinyint/bool type from mysql to number instead of bool to match
mariadb and mysql2 behavior since tinyint/bool can be bigger than 1 in
mysql
Fixes https://github.com/oven-sh/bun/issues/22158
### How did you verify your code works?
Test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Support the following:
```javascript
const nom = await sql`SELECT name FROM food WHERE category IN ${sql(['bun', 'baozi', 'xiaolongbao'])}`;
```
Previously, only e.g., `sql([1, 2, 3])` was supported.
To be honest I'm not sure what the semantics of SQLHelper *ought* to be.
I'm pretty sure objects ought to be auto-inferred. I'm not sure about
arrays, but given the rest of the code in `SQLHelper` trying to read the
tea leaves on stringified numeric keys I figured someone cared about
this use case. I don't know about other types, but I'm pretty sure that
`Object.keys("bun") === [0, 1, 2]` is an oversight and unintended.
(Incidentally, the reason numbers previously worked is because
`Object.keys(4) === []`). I decided that all non-objects and non-arrays
should be treated as not having auto-inferred columns.
Fixes#18637
### How did you verify your code works?
I wrote a test, but was unable to run it (or any other tests in this
file) locally due to Docker struggles. I sure hope it works!
### What does this PR do?
Fixes#20729
### How did you verify your code works?
There is a test
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Add MySQL support, Refactor will be in a followup PR
### How did you verify your code works?
A lot of tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: cirospaciari <6379399+cirospaciari@users.noreply.github.com>
### What does this PR do?
Support sqlite in the Bun.sql API
Fixes#18951Fixes#19701
### How did you verify your code works?
tests
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
### What does this PR do?
We should not call .deinit() after .toJS otherwise hasPendingActivity
will access invalid memory
### How did you verify your code works?
Test run it with debug build on macos or asan on and will catch it
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
### What does this PR do?
Fix: https://github.com/oven-sh/bun/issues/21351
Relevant changes:
Fix advance to properly cleanup success and failed queries that could be
still be in the queue
Always ref before executing
Use stronger atomics for ref/deref and hasPendingActivity
Fallback when thisValue is freed/null/zero and check if vm is being
shutdown
The bug in --hot in `resolveRopeIfNeeded` Issue is not meant to be fixed
in this PR this is a fix for the postgres regression
Added assertions so this bug is easier to catch on CI
### How did you verify your code works?
Test added
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>