Skip to content

Commit d0815c5

Browse files
authored
Merge branch 'launchbadge:main' into postgres-not-exist
2 parents 89a22e3 + f5cdf33 commit d0815c5

File tree

29 files changed

+614
-558
lines changed

29 files changed

+614
-558
lines changed

Cargo.lock

Lines changed: 4 additions & 13 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/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ tokio = { workspace = true, optional = true }
5656
native-tls = { version = "0.2.10", optional = true }
5757

5858
rustls = { version = "0.23.24", default-features = false, features = ["std", "tls12"], optional = true }
59-
webpki-roots = { version = "0.26", optional = true }
59+
webpki-roots = { version = "1", optional = true }
6060
rustls-native-certs = { version = "0.8.0", optional = true }
6161

6262
# Type Integrations

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/sql_str.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@ use std::sync::Arc;
3535
/// [injection]: https://en.wikipedia.org/wiki/SQL_injection
3636
/// [`query()`]: crate::query::query
3737
/// [`raw_sql()`]: crate::raw_sql::raw_sql
38+
#[diagnostic::on_unimplemented(
39+
label = "dynamic SQL string",
40+
message = "dynamic SQL strings should be audited for possible injections",
41+
note = "prefer literal SQL strings with bind parameters or `QueryBuilder` to add dynamic data to a query.
42+
43+
To bypass this error, manually audit for potential injection vulnerabilities and wrap with `AssertSqlSafe()`.
44+
For details, see the docs for `SqlSafeStr`.\n",
45+
note = "this trait is only implemented for `&'static str`, not all `&str` like the compiler error may suggest"
46+
)]
3847
pub trait SqlSafeStr {
3948
/// Convert `self` to a [`SqlStr`].
4049
fn into_sql_str(self) -> SqlStr;

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"

0 commit comments

Comments
 (0)