Skip to content
Merged
Changes from 2 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
21 changes: 21 additions & 0 deletions src/sql/db_connection_pool/mysqlpool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ pub enum Error {

#[snafu(display("{message}\nEnsure the given MySQL database exists"))]
UnknownMySQLDatabase { message: String },

#[snafu(display("Unsupported value: '{value}' for 'character_set_results'. Only 'utf8mb3' and 'utf8mb4' are supported."))]
InvalidCharacterSetResults { value: String },
}

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -160,6 +163,24 @@ impl MySQLConnectionPool {

connection_string = connection_string.ssl_opts(ssl_opts);

if let Some(mysql_character_set_results) = params
.get("character_set_results")
.map(SecretBox::expose_secret)
{
match mysql_character_set_results {
"utf8mb3" | "utf8mb4" => {
Comment thread
phillipleblanc marked this conversation as resolved.
Outdated
connection_string = connection_string.setup(vec![format!(
"SET character_set_results = {mysql_character_set_results}"
)]);
}
_ => {
return Err(Error::InvalidCharacterSetResults {
value: mysql_character_set_results.to_string(),
})
}
}
}

let opts = mysql_async::Opts::from(connection_string);

verify_mysql_opts(&opts).await?;
Expand Down