Skip to content

Commit 0ab5848

Browse files
committed
breaking: make offline optional to allow building without serde
1 parent e8384f2 commit 0ab5848

File tree

25 files changed

+98
-30
lines changed

25 files changed

+98
-30
lines changed

Cargo.lock

Lines changed: 0 additions & 1 deletion
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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1-
use crate::any::{Any, AnyArguments, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
1+
#[cfg(feature = "offline")]
2+
use crate::any::Any;
3+
use crate::any::{AnyArguments, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
4+
#[cfg(feature = "offline")]
25
use crate::describe::Describe;
36
use crate::sql_str::SqlStr;
47
use either::Either;
@@ -114,5 +117,6 @@ pub trait AnyConnectionBackend: std::any::Any + Debug + Send + 'static {
114117
parameters: &[AnyTypeInfo],
115118
) -> BoxFuture<'c, crate::Result<AnyStatement>>;
116119

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::any::{Any, AnyConnection, AnyQueryResult, AnyRow, AnyStatement, AnyTypeInfo};
2+
#[cfg(feature = "offline")]
23
use crate::describe::Describe;
34
use crate::error::Error;
45
use crate::executor::{Execute, Executor};
@@ -56,6 +57,7 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
5657
self.backend.prepare_with(sql, parameters)
5758
}
5859

60+
#[cfg(feature = "offline")]
5961
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
6062
where
6163
'c: 'e,

sqlx-core/src/executor.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::database::Database;
2+
#[cfg(feature = "offline")]
23
use crate::describe::Describe;
34
use crate::error::{BoxDynError, Error};
45
use crate::sql_str::{SqlSafeStr, SqlStr};
@@ -178,6 +179,7 @@ pub trait Executor<'c>: Send + Debug + Sized {
178179
/// This is used by compile-time verification in the query macros to
179180
/// power their type inference.
180181
#[doc(hidden)]
182+
#[cfg(feature = "offline")]
181183
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>>
182184
where
183185
'c: 'e;

sqlx-core/src/pool/executor.rs

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

66
use crate::database::Database;
7+
#[cfg(feature = "offline")]
78
use crate::describe::Describe;
89
use crate::error::Error;
910
use crate::executor::{Execute, Executor};
@@ -63,6 +64,7 @@ where
6364
}
6465

6566
#[doc(hidden)]
67+
#[cfg(feature = "offline")]
6668
fn describe<'e>(self, sql: SqlStr) -> BoxFuture<'e, Result<Describe<Self::Database>, Error>> {
6769
let pool = self.clone();
6870

@@ -127,6 +129,7 @@ where
127129
// }
128130
//
129131
// #[doc(hidden)]
132+
// #[cfg(feature = "offline")]
130133
// #[inline]
131134
// fn describe<'e, 'q: 'e>(
132135
// 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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,15 @@ use either::Either;
77
use futures_core::future::BoxFuture;
88
use futures_core::stream::BoxStream;
99
use futures_util::{stream, FutureExt, StreamExt, TryFutureExt, TryStreamExt};
10+
#[cfg(feature = "offline")]
11+
use sqlx_core::any::Any;
1012
use sqlx_core::any::{
11-
Any, AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
13+
AnyArguments, AnyColumn, AnyConnectOptions, AnyConnectionBackend, AnyQueryResult, AnyRow,
1214
AnyStatement, AnyTypeInfo, AnyTypeInfoKind,
1315
};
1416
use sqlx_core::connection::Connection;
1517
use sqlx_core::database::Database;
18+
#[cfg(feature = "offline")]
1619
use sqlx_core::describe::Describe;
1720
use sqlx_core::executor::Executor;
1821
use sqlx_core::sql_str::SqlStr;
@@ -141,6 +144,7 @@ impl AnyConnectionBackend for MySqlConnection {
141144
})
142145
}
143146

147+
#[cfg(feature = "offline")]
144148
fn describe(&mut self, sql: SqlStr) -> BoxFuture<'_, sqlx_core::Result<Describe<Any>>> {
145149
Box::pin(async move {
146150
let describe = Executor::describe(self, sql).await?;

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(dead_code)]
1617
#[cfg_attr(feature = "offline", serde(skip))]
1718
pub(crate) flags: Option<ColumnFlags>,
1819
}

0 commit comments

Comments
 (0)