diff --git a/sqlx-core/src/config/drivers.rs b/sqlx-core/src/config/drivers.rs
index c3416541cd..dd5452fb5a 100644
--- a/sqlx-core/src/config/drivers.rs
+++ b/sqlx-core/src/config/drivers.rs
@@ -40,14 +40,38 @@ pub struct Config {
}
/// Configuration for the MySQL database driver.
-#[derive(Debug, Default)]
+#[derive(Debug)]
#[cfg_attr(
feature = "sqlx-toml",
derive(serde::Deserialize),
serde(default, rename_all = "kebab-case", deny_unknown_fields)
)]
pub struct MySqlConfig {
- // No fields implemented yet. This key is only used to validate parsing.
+ /// Whether to enable the `PIPES_AS_CONCAT` connection setting
+ ///
+ /// Defaults to `true`.
+ ///
+ /// Some MySql databases such as PlanetScale error out with this connection setting
+ /// so it needs to be set `false` in such cases.
+ pub pipes_as_concat: bool,
+ /// Whether to enable the `NO_ENGINE_SUBSTITUTION` sql_mode setting after connection.
+ ///
+ /// Defaults to `true` (`NO_ENGINE_SUBSTITUTION` is passed, forbidding engine substitution.)
+ ///
+ /// If not set, if the available storage engine specified by a `CREATE TABLE` is not available,
+ /// a warning is given and the default storage engine is used instead.
+ ///
+ ///
+ pub no_engine_substitution: bool,
+}
+
+impl Default for MySqlConfig {
+ fn default() -> Self {
+ Self {
+ pipes_as_concat: true,
+ no_engine_substitution: true,
+ }
+ }
}
/// Configuration for the Postgres database driver.
diff --git a/sqlx-core/src/config/reference.toml b/sqlx-core/src/config/reference.toml
index 618ac23c91..3585f740f8 100644
--- a/sqlx-core/src/config/reference.toml
+++ b/sqlx-core/src/config/reference.toml
@@ -22,7 +22,20 @@ database-url-var = "FOO_DATABASE_URL"
# Configure MySQL databases in macros and sqlx-cli.
[drivers.mysql]
-# No fields implemented yet. This key is only used to validate parsing.
+# Whether to enable the `PIPES_AS_CONCAT` connection setting
+#
+# Defaults to `true`.
+#
+# Some MySql databases such as PlanetScale error out with this connection setting
+# so it needs to be set `false` in such cases.
+pipes-as-concat = false
+# Whether to enable the `NO_ENGINE_SUBSTITUTION` sql_mode setting after connection.
+#
+# Defaults to `true` (`NO_ENGINE_SUBSTITUTION` is passed, forbidding engine substitution.)
+#
+# If not set, if the available storage engine specified by a `CREATE TABLE` is not available,
+# a warning is given and the default storage engine is used instead.
+no-engine-substitution = false
# Configure Postgres databases in macros and sqlx-cli.
[drivers.postgres]
diff --git a/sqlx-core/src/config/tests.rs b/sqlx-core/src/config/tests.rs
index d01b859e46..4f1ee36535 100644
--- a/sqlx-core/src/config/tests.rs
+++ b/sqlx-core/src/config/tests.rs
@@ -18,6 +18,9 @@ fn assert_common_config(config: &config::common::Config) {
}
fn assert_drivers_config(config: &config::drivers::Config) {
+ assert!(!config.mysql.pipes_as_concat);
+ assert!(!config.mysql.no_engine_substitution);
+
assert_eq!(
config.sqlite.unsafe_load_extensions,
vec![
diff --git a/sqlx-core/src/connection.rs b/sqlx-core/src/connection.rs
index b5f8138b2b..c7208bce9d 100644
--- a/sqlx-core/src/connection.rs
+++ b/sqlx-core/src/connection.rs
@@ -179,6 +179,29 @@ pub trait Connection: Send {
async move { Self::connect_with(&options?).await }
}
+ /// UNSTABLE: for use with `sqlx-macros-core`
+ ///
+ /// Establish a new database connection.
+ ///
+ /// A value of [`Options`][Self::Options] is first parsed from the provided connection string.
+ /// This parsing is database-specific.
+ /// The option then gets updated with options from the sqlx.toml file as appropriate.
+ #[doc(hidden)]
+ #[inline]
+ fn connect_with_driver_config(
+ url: &str,
+ driver_config: &config::drivers::Config,
+ ) -> impl Future