Skip to content

Commit 7bc1399

Browse files
committed
breaking: make offline optional to allow building without serde
1 parent 4e72b0e commit 7bc1399

File tree

26 files changed

+115
-65
lines changed

26 files changed

+115
-65
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ rustdoc-args = ["--cfg", "docsrs"]
6363
default = ["any", "macros", "migrate", "json"]
6464

6565
derive = ["sqlx-macros/derive"]
66-
macros = ["derive", "sqlx-macros/macros"]
66+
macros = ["derive", "sqlx-macros/macros", "sqlx-core/offline", "sqlx-mysql?/offline", "sqlx-postgres?/offline", "sqlx-sqlite?/offline"]
6767
migrate = ["sqlx-core/migrate", "sqlx-macros?/migrate", "sqlx-mysql?/migrate", "sqlx-postgres?/migrate", "sqlx-sqlite?/migrate"]
6868

6969
# Enable parsing of `sqlx.toml` for configuring macros and migrations.
@@ -211,7 +211,7 @@ features = ["time", "net", "sync", "fs", "io-util", "rt"]
211211
default-features = false
212212

213213
[dependencies]
214-
sqlx-core = { workspace = true, features = ["offline", "migrate"] }
214+
sqlx-core = { workspace = true, features = ["migrate"] }
215215
sqlx-macros = { workspace = true, optional = true }
216216

217217
sqlx-mysql = { workspace = true, optional = true }

sqlx-core/src/any/connection/backend.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
use crate::any::{Any, AnyArguments, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
2-
use crate::describe::Describe;
1+
use crate::any::{AnyArguments, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
32
use crate::sql_str::SqlStr;
43
use either::Either;
54
use futures_core::future::BoxFuture;
@@ -114,5 +113,9 @@ pub trait AnyConnectionBackend: std::any::Any + Debug + Send + 'static {
114113
parameters: &[AnyTypeInfo],
115114
) -> BoxFuture<'c, crate::Result<AnyStatement>>;
116115

117-
fn describe(&mut self, sql: SqlStr) -> BoxFuture<'_, crate::Result<Describe<Any>>>;
116+
#[cfg(feature = "offline")]
117+
fn describe(
118+
&mut self,
119+
sql: SqlStr,
120+
) -> BoxFuture<'_, crate::Result<crate::describe::Describe<crate::any::Any>>>;
118121
}

sqlx-core/src/any/connection/executor.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::any::{Any, AnyConnection, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
2-
use crate::describe::Describe;
32
use crate::error::Error;
43
use crate::executor::{Execute, Executor};
54
use crate::sql_str::SqlStr;
@@ -56,7 +55,11 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
5655
self.backend.prepare_with(sql, parameters)
5756
}
5857

59-
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
58+
#[cfg(feature = "offline")]
59+
fn describe<'e>(
60+
self,
61+
sql: SqlStr,
62+
) -> BoxFuture<'e, Result<crate::describe::Describe<Self::Database>, Error>>
6063
where
6164
'c: 'e,
6265
{

sqlx-core/src/executor.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use crate::database::Database;
2-
use crate::describe::Describe;
32
use crate::error::{BoxDynError, Error};
43
use crate::sql_str::{SqlSafeStr, SqlStr};
54

@@ -178,7 +177,11 @@ pub trait Executor<'c>: Send + Debug + Sized {
178177
/// This is used by compile-time verification in the query macros to
179178
/// power their type inference.
180179
#[doc(hidden)]
181-
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
180+
#[cfg(feature = "offline")]
181+
fn describe<'e>(
182+
self,
183+
sql: SqlStr,
184+
) -> BoxFuture<'e, Result<crate::describe::Describe<Self::Database>, Error>>
182185
where
183186
'c: 'e;
184187
}

sqlx-core/src/pool/executor.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use futures_core::stream::BoxStream;
44
use futures_util::TryStreamExt;
55

66
use crate::database::Database;
7-
use crate::describe::Describe;
87
use crate::error::Error;
98
use crate::executor::{Execute, Executor};
109
use crate::pool::Pool;
@@ -63,7 +62,11 @@ where
6362
}
6463

6564
#[doc(hidden)]
66-
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>> {
65+
#[cfg(feature = "offline")]
66+
fn describe<'e>(
67+
self,
68+
sql: SqlStr,
69+
) -> BoxFuture<'e, Result<crate::describe::Describe<Self::Database>, Error>> {
6770
let pool = self.clone();
6871

6972
Box::pin(async move { pool.acquire().await?.describe(sql).await })
@@ -127,6 +130,7 @@ where
127130
// }
128131
//
129132
// #[doc(hidden)]
133+
// #[cfg(feature = "offline")]
130134
// #[inline]
131135
// fn describe<'e, 'q: 'e>(
132136
// self,

sqlx-core/src/transaction.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ where
189189
// }
190190
//
191191
// #[doc(hidden)]
192+
// #[cfg(feature = "offline")]
192193
// fn describe<'e, 'q: 'e>(
193194
// self,
194195
// query: &'q str,

sqlx-mysql/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ rust-version.workspace = true
1212
[features]
1313
json = ["sqlx-core/json", "serde"]
1414
any = ["sqlx-core/any"]
15-
offline = ["sqlx-core/offline", "serde/derive"]
15+
offline = ["sqlx-core/offline", "serde/derive", "bitflags/serde"]
1616
migrate = ["sqlx-core/migrate"]
1717

1818
# Type Integration features
@@ -52,7 +52,7 @@ uuid = { workspace = true, optional = true }
5252
# Misc
5353
atoi = "2.0"
5454
base64 = { version = "0.22.0", default-features = false, features = ["std"] }
55-
bitflags = { version = "2", default-features = false, features = ["serde"] }
55+
bitflags = { version = "2", default-features = false }
5656
byteorder = { version = "1.4.3", default-features = false, features = ["std"] }
5757
bytes = "1.1.0"
5858
either = "1.6.1"

sqlx-mysql/src/any.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ use futures_core::future::BoxFuture;
88
use futures_core::stream::BoxStream;
99
use futures_util::{stream, FutureExt, StreamExt, TryFutureExt, TryStreamExt};
1010
use sqlx_core::any::{
11-
Any, AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
11+
AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
1212
AnyStatement, AnyTypeInfo, AnyTypeInfoKind,
1313
};
1414
use sqlx_core::connection::Connection;
1515
use sqlx_core::database::Database;
16-
use sqlx_core::describe::Describe;
1716
use sqlx_core::executor::Executor;
1817
use sqlx_core::sql_str::SqlStr;
1918
use sqlx_core::transaction::TransactionManager;
@@ -141,7 +140,11 @@ impl AnyConnectionBackend for MySqlConnection {
141140
})
142141
}
143142

144-
fn describe(&mut self, sql: SqlStr) -> BoxFuture<'_, sqlx_core::Result<Describe<Any>>> {
143+
#[cfg(feature = "offline")]
144+
fn describe(
145+
&mut self,
146+
sql: SqlStr,
147+
) -> BoxFuture<'_, sqlx_core::Result<sqlx_core::describe::Describe<sqlx_core::any::Any>>> {
145148
Box::pin(async move {
146149
let describe = Executor::describe(self, sql).await?;
147150
describe.try_into_any()

sqlx-mysql/src/column.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub struct MySqlColumn {
1313
#[cfg_attr(feature = "offline", serde(default))]
1414
pub(crate) origin: ColumnOrigin,
1515

16+
#[allow(unused)]
1617
#[cfg_attr(feature = "offline", serde(skip))]
1718
pub(crate) flags: Option<ColumnFlags>,
1819
}

0 commit comments

Comments
 (0)