Skip to content

Commit

Permalink
fix(mysql): percent-decode database name (#3612)
Browse files Browse the repository at this point in the history
Duplicates the fix to Postgres in #3593 to the MySQL driver.

The SQLite driver already does this: https://github.com/launchbadge/sqlx/blob/e3ef8baf23bc0266959282814c014e482418eef2/sqlx-sqlite/src/options/parse.rs#L29-L32
  • Loading branch information
abonander authored Nov 27, 2024
1 parent 94607b5 commit 35f3ec1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion sqlx-mysql/src/options/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ impl MySqlConnectOptions {

let path = url.path().trim_start_matches('/');
if !path.is_empty() {
options = options.database(path);
options = options.database(
&percent_decode_str(path)
.decode_utf8()
.map_err(Error::config)?,
);
}

for (key, value) in url.query_pairs().into_iter() {
Expand Down

0 comments on commit 35f3ec1

Please sign in to comment.