Skip to content

Commit ba23fde

Browse files
authored
Compile-time support for external drivers (#3889)
* Make sqlx-macros-core::database public * Move driver installation to bins * Fix lint
1 parent a0e4054 commit ba23fde

File tree

5 files changed

+6
-3
lines changed

5 files changed

+6
-3
lines changed

sqlx-cli/src/bin/cargo-sqlx.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ enum Cli {
1515
async fn main() {
1616
sqlx_cli::maybe_apply_dotenv();
1717

18+
sqlx::any::install_default_drivers();
19+
1820
let Cli::Sqlx(opt) = Cli::parse();
1921

2022
if let Err(error) = sqlx_cli::run(opt).await {

sqlx-cli/src/bin/sqlx.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ async fn main() {
77
// Checks for `--no-dotenv` before parsing.
88
sqlx_cli::maybe_apply_dotenv();
99

10+
sqlx::any::install_default_drivers();
11+
1012
let opt = Opt::parse();
1113

1214
// no special handling here

sqlx-cli/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,6 @@ where
204204
F: FnMut(&'a str) -> Fut,
205205
Fut: Future<Output = sqlx::Result<T>> + 'a,
206206
{
207-
sqlx::any::install_default_drivers();
208-
209207
let db_url = opts.expect_db_url()?;
210208

211209
backoff::future::retry(

sqlx-macros-core/src/database/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ pub struct CachingDescribeBlocking<DB: DatabaseExt> {
3333

3434
#[allow(dead_code)]
3535
impl<DB: DatabaseExt> CachingDescribeBlocking<DB> {
36+
#[allow(clippy::new_without_default, reason = "internal API")]
3637
pub const fn new() -> Self {
3738
CachingDescribeBlocking {
3839
connections: LazyLock::new(|| Mutex::new(HashMap::new())),

sqlx-macros-core/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub type Error = Box<dyn std::error::Error>;
2727
pub type Result<T> = std::result::Result<T, Error>;
2828

2929
mod common;
30-
mod database;
30+
pub mod database;
3131

3232
#[cfg(feature = "derive")]
3333
pub mod derives;

0 commit comments

Comments
 (0)