Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
466e195
Add clippy checks and suppress doctest warning
cursoragent Sep 16, 2025
aa47d8a
Refactor: Add 'q lifetime bound to Execute trait
cursoragent Sep 16, 2025
a7dda12
Refactor: Improve sqlx code quality and fix minor issues
cursoragent Sep 16, 2025
be77046
fix: resolve clippy warnings in pool/inner.rs
cursoragent Sep 16, 2025
e23d880
fix: resolve additional clippy warnings
cursoragent Sep 16, 2025
609db87
fix: resolve clippy warnings in query, io, and tls modules
cursoragent Sep 16, 2025
eb5177d
fix: resolve more clippy warnings
cursoragent Sep 16, 2025
1ae9134
fix: resolve auto-deref and other clippy warnings
cursoragent Sep 16, 2025
62535fa
fix: resolve redundant closures and more auto-deref warnings
cursoragent Sep 16, 2025
b1bcbc1
fix: apply automatic clippy fixes and resolve type conversion issues
cursoragent Sep 16, 2025
b064905
fix: resolve remaining simple clippy warnings
cursoragent Sep 16, 2025
37a1502
fix: resolve large enum variant and naming warnings
cursoragent Sep 16, 2025
124af64
Refactor: Improve TLS stream handling and add test script
cursoragent Sep 16, 2025
28311cd
Checkpoint before follow-up message
cursoragent Sep 16, 2025
41f4475
fix: clippy warnings for mssql, any, postgres, and sqlite modules
cursoragent Sep 16, 2025
cfd6713
fix: more clippy warnings in sqlite and logger modules
cursoragent Sep 16, 2025
2d30b57
fix: more clippy warnings in sqlite modules
cursoragent Sep 16, 2025
0715089
fix: clippy warnings for mysql and final sqlite modules
cursoragent Sep 16, 2025
42bba3a
fix: more clippy warnings in mysql modules
cursoragent Sep 16, 2025
ad510f2
fix: clippy warnings in mysql types and migrate modules
cursoragent Sep 16, 2025
6df4fdb
fix: clippy warnings in mysql testing and mssql modules
cursoragent Sep 16, 2025
de1dfa9
fix: more clippy warnings in mssql modules
cursoragent Sep 16, 2025
95d02e1
fix: final clippy warnings in mssql modules
cursoragent Sep 16, 2025
f8fe6ca
fix: platform-specific return type for async-std in tls_prelogin_stre…
cursoragent Sep 16, 2025
c64bbfe
Refactor: Remove unused blank lines and reorder imports
cursoragent Sep 16, 2025
0df05eb
fix: clippy warnings in tests and macros
cursoragent Sep 16, 2025
b01e473
cargo fmt
lovasoa Sep 16, 2025
b238bdb
fix: update type annotations for DateTime in MySQL tests
lovasoa Sep 16, 2025
7f28d0e
refactor: remove unused custom domain type and update imports in tests
lovasoa Sep 16, 2025
ef3c39b
fix: correct error handling in native-tls downgrade message
lovasoa Sep 16, 2025
886740e
refactor: streamline clippy checks in CI workflow
lovasoa Sep 16, 2025
4893583
fix: update lint configurations and suppress unused import warnings i…
lovasoa Sep 16, 2025
3a1ac1f
fmt
lovasoa Sep 16, 2025
9c4c51d
chore: add unused import suppressions in test files
lovasoa Sep 16, 2025
d595264
refactor: remove test_all_features.sh script and suppress unused impo…
lovasoa Sep 16, 2025
fd74cc4
refactor: rename from_label_iter to from_iter for consistency
lovasoa Sep 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/sqlx.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
- uses: actions/checkout@v4
- run: cargo fmt --all -- --check


check:
name: Check
runs-on: ubuntu-22.04
Expand All @@ -40,6 +41,25 @@ jobs:
--no-default-features
--lib --tests
--features offline,all-databases,migrate,runtime-${{ matrix.runtime }}-${{ matrix.tls }}
- name: Run clippy for core with all features
run: |
cargo clippy --manifest-path sqlx-core/Cargo.toml \
--no-default-features \
--features offline,all-databases,all-types,migrate,runtime-${{ matrix.runtime }}-${{ matrix.tls }} \
-- -D warnings
- name: Run clippy for root with all features
run: |
cargo clippy \
--no-default-features \
--features offline,all-databases,all-types,migrate,runtime-${{ matrix.runtime }}-${{ matrix.tls }},macros \
-- -D warnings
- name: Run clippy for all targets
run: |
cargo clippy \
--no-default-features \
--all-targets \
--features offline,all-databases,migrate,runtime-${{ matrix.runtime }}-${{ matrix.tls }} \
-- -D warnings

test:
name: Unit Test
Expand Down Expand Up @@ -98,6 +118,7 @@ jobs:
name: cargo-sqlx-${{ matrix.target }}
path: ${{ matrix.bin }}


sqlite:
name: SQLite
runs-on: ubuntu-22.04
Expand All @@ -110,6 +131,12 @@ jobs:
- uses: actions/checkout@v4
- run: mkdir /tmp/sqlite3-lib && wget -O /tmp/sqlite3-lib/ipaddr.so https://github.com/nalgeon/sqlean/releases/download/0.15.2/ipaddr.so
- uses: Swatinem/rust-cache@v2
- name: Run clippy for sqlite
run: |
cargo clippy \
--no-default-features \
--features sqlite,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }},macros,migrate \
-- -D warnings
- run:
cargo test
--no-default-features
Expand Down Expand Up @@ -153,6 +180,15 @@ jobs:
args: >
--features postgres,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}

- name: Run clippy for postgres
run: |
cargo clippy \
--no-default-features \
--features postgres,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }},macros,migrate \
-- -D warnings
env:
RUSTFLAGS: --cfg postgres_${{ matrix.postgres }}

- run: |
docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_${{ matrix.postgres }} postgres_${{ matrix.postgres }}
docker exec postgres_${{ matrix.postgres }} bash -c "until pg_isready; do sleep 1; done"
Expand Down Expand Up @@ -224,6 +260,13 @@ jobs:
args: >
--features mysql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}

- name: Run clippy for mysql
run: |
cargo clippy \
--no-default-features \
--features mysql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }},macros,migrate \
-- -D warnings

- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 mysql_${{ matrix.mysql }}
- run: sleep 60

Expand Down Expand Up @@ -275,6 +318,13 @@ jobs:
args: >
--features mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }}

- name: Run clippy for mariadb
run: |
cargo clippy \
--no-default-features \
--features mysql,runtime-${{ matrix.runtime }}-${{ matrix.tls }},macros,migrate \
-- -D warnings

- run: docker compose -f tests/docker-compose.yml run -d -p 3306:3306 mariadb_${{ matrix.mariadb }}
- run: sleep 30

Expand Down Expand Up @@ -315,6 +365,13 @@ jobs:
args: >
--features mssql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }}

- name: Run clippy for mssql
run: |
cargo clippy \
--no-default-features \
--features mssql,all-types,runtime-${{ matrix.runtime }}-${{ matrix.tls }},macros,migrate \
-- -D warnings

- run: docker compose -f tests/docker-compose.yml run -d -p 1433:1433 mssql_${{ matrix.mssql }}
- run: sleep 80 # MSSQL takes a "bit" to startup

Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ members = [
"examples/sqlite/todos",
]

[workspace.lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(postgres_14)', 'cfg(postgres_9_6)'] }

[package]
name = "sqlx-oldapi"
version = "0.6.48"
Expand Down
8 changes: 4 additions & 4 deletions sqlx-core/src/any/connection/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@ use futures_util::{StreamExt, TryStreamExt};
impl<'c> Executor<'c> for &'c mut AnyConnection {
type Database = Any;

fn fetch_many<'e, 'q: 'e, E: 'q>(
fn fetch_many<'e, 'q: 'e, E>(
self,
mut query: E,
) -> BoxStream<'e, Result<Either<AnyQueryResult, AnyRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
let arguments = query.take_arguments();
let query = query.sql();
Expand Down Expand Up @@ -52,13 +52,13 @@ impl<'c> Executor<'c> for &'c mut AnyConnection {
}
}

fn fetch_optional<'e, 'q: 'e, E: 'q>(
fn fetch_optional<'e, 'q: 'e, E>(
self,
mut query: E,
) -> BoxFuture<'e, Result<Option<AnyRow>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
let arguments = query.take_arguments();
let query = query.sql();
Expand Down
1 change: 1 addition & 0 deletions sqlx-core/src/any/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub struct AnyConnection(pub(super) AnyConnectionKind);
#[derive(Debug)]
// Used internally in `sqlx-macros`
#[doc(hidden)]
#[allow(clippy::large_enum_variant)]
pub enum AnyConnectionKind {
#[cfg(feature = "postgres")]
Postgres(postgres::PgConnection),
Expand Down
4 changes: 2 additions & 2 deletions sqlx-core/src/any/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl<'q> Statement<'q> for AnyStatement<'q> {

fn parameters(&self) -> Option<Either<&[AnyTypeInfo], usize>> {
match &self.parameters {
Some(Either::Left(types)) => Some(Either::Left(&types)),
Some(Either::Left(types)) => Some(Either::Left(types)),
Some(Either::Right(count)) => Some(Either::Right(*count)),
None => None,
}
Expand All @@ -54,7 +54,7 @@ where
statement
.column_names
.get(*self)
.copied()
.ok_or_else(|| Error::ColumnNotFound((*self).into()))
.map(|v| *v)
}
}
1 change: 1 addition & 0 deletions sqlx-core/src/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub trait IntoArguments<'q, DB: HasArguments<'q>>: Sized + Send {

// NOTE: required due to lack of lazy normalization
#[allow(unused_macros)]
#[allow(clippy::needless_doctest_main)]
macro_rules! impl_into_arguments_for_arguments {
($Arguments:path) => {
impl<'q>
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub trait Connection: Send {
{
let options = url.parse();

Box::pin(async move { Ok(Self::connect_with(&options?).await?) })
Box::pin(async move { Self::connect_with(&options?).await })
}

/// Establish a new database connection with the provided options.
Expand Down
28 changes: 14 additions & 14 deletions sqlx-core/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,25 @@ pub trait Executor<'c>: Send + Debug + Sized {
type Database: Database;

/// Execute the query and return the total number of rows affected.
fn execute<'e, 'q: 'e, E: 'q>(
fn execute<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::QueryResult, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
self.execute_many(query).try_collect().boxed()
}

/// Execute multiple queries and return the rows affected from each query, in a stream.
fn execute_many<'e, 'q: 'e, E: 'q>(
fn execute_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::QueryResult, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
self.fetch_many(query)
.try_filter_map(|step| async move {
Expand All @@ -57,13 +57,13 @@ pub trait Executor<'c>: Send + Debug + Sized {
}

/// Execute the query and return the generated results as a stream.
fn fetch<'e, 'q: 'e, E: 'q>(
fn fetch<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<'e, Result<<Self::Database as Database>::Row, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
self.fetch_many(query)
.try_filter_map(|step| async move {
Expand All @@ -77,7 +77,7 @@ pub trait Executor<'c>: Send + Debug + Sized {

/// Execute multiple queries and return the generated results as a stream
/// from each query, in a stream.
fn fetch_many<'e, 'q: 'e, E: 'q>(
fn fetch_many<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxStream<
Expand All @@ -89,28 +89,28 @@ pub trait Executor<'c>: Send + Debug + Sized {
>
where
'c: 'e,
E: Execute<'q, Self::Database>;
E: Execute<'q, Self::Database> + 'q;

/// Execute the query and return all the generated results, collected into a [`Vec`].
fn fetch_all<'e, 'q: 'e, E: 'q>(
fn fetch_all<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Vec<<Self::Database as Database>::Row>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
self.fetch(query).try_collect().boxed()
}

/// Execute the query and returns exactly one row.
fn fetch_one<'e, 'q: 'e, E: 'q>(
fn fetch_one<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<<Self::Database as Database>::Row, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>,
E: Execute<'q, Self::Database> + 'q,
{
self.fetch_optional(query)
.and_then(|row| match row {
Expand All @@ -121,13 +121,13 @@ pub trait Executor<'c>: Send + Debug + Sized {
}

/// Execute the query and returns at most one row.
fn fetch_optional<'e, 'q: 'e, E: 'q>(
fn fetch_optional<'e, 'q: 'e, E>(
self,
query: E,
) -> BoxFuture<'e, Result<Option<<Self::Database as Database>::Row>, Error>>
where
'c: 'e,
E: Execute<'q, Self::Database>;
E: Execute<'q, Self::Database> + 'q;

/// Prepare the SQL query to inspect the type information of its parameters
/// and results.
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/ext/ustr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ impl serde::Serialize for UStr {
where
S: serde::Serializer,
{
serializer.serialize_str(&self)
serializer.serialize_str(self)
}
}
4 changes: 2 additions & 2 deletions sqlx-core/src/io/buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub trait BufExt: Buf {
impl BufExt for Bytes {
fn get_bytes_nul(&mut self) -> Result<Bytes, Error> {
let nul =
memchr(b'\0', &self).ok_or_else(|| err_protocol!("expected NUL in byte sequence"))?;
memchr(b'\0', self).ok_or_else(|| err_protocol!("expected NUL in byte sequence"))?;

let v = self.slice(0..nul);

Expand All @@ -40,7 +40,7 @@ impl BufExt for Bytes {

fn get_str_nul(&mut self) -> Result<String, Error> {
self.get_bytes_nul().and_then(|bytes| {
from_utf8(&*bytes)
from_utf8(&bytes)
.map(ToOwned::to_owned)
.map_err(|err| err_protocol!("{}", err))
})
Expand Down
8 changes: 2 additions & 6 deletions sqlx-core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,8 @@
#![recursion_limit = "512"]
#![warn(future_incompatible, rust_2018_idioms)]
#![allow(clippy::needless_doctest_main, clippy::type_complexity, dead_code)]
#![deny(
clippy::cast_possible_truncation,
clippy::cast_possible_wrap,
clippy::cast_precision_loss,
clippy::cast_sign_loss
)]
// Note: Cast warnings are allowed on a case-by-case basis with explicit #[allow(...)]
// This ensures we're aware of potential issues with numeric conversions
// See `clippy.toml` at the workspace root
#![deny(clippy::disallowed_methods)]
//
Expand Down
13 changes: 4 additions & 9 deletions sqlx-core/src/logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'q> QueryLogger<'q> {
.to_level()
.filter(|lvl| log::log_enabled!(target: "sqlx::query", *lvl))
{
let mut summary = parse_query_summary(&self.sql);
let mut summary = parse_query_summary(self.sql);

let sql = if summary != self.sql {
summary.push_str(" …");
Expand Down Expand Up @@ -99,16 +99,11 @@ impl<'q, O: Debug + Hash + Eq, R: Debug, P: Debug> QueryPlanLogger<'q, O, R, P>
}

pub(crate) fn log_enabled(&self) -> bool {
if let Some(_lvl) = self
.settings
self.settings
.statements_level
.to_level()
.filter(|lvl| log::log_enabled!(target: "sqlx::explain", *lvl))
{
return true;
} else {
return false;
}
.is_some()
}

pub(crate) fn add_result(&mut self, result: R) {
Expand All @@ -126,7 +121,7 @@ impl<'q, O: Debug + Hash + Eq, R: Debug, P: Debug> QueryPlanLogger<'q, O, R, P>
.to_level()
.filter(|lvl| log::log_enabled!(target: "sqlx::explain", *lvl))
{
let mut summary = parse_query_summary(&self.sql);
let mut summary = parse_query_summary(self.sql);

let sql = if summary != self.sql {
summary.push_str(" …");
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/mssql/arguments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ impl MssqlArguments {
// @p1 int, @p2 nvarchar(10), ...

if !declarations.is_empty() {
declarations.push_str(",");
declarations.push(',');
}

declarations.push_str(name);
Expand Down
2 changes: 1 addition & 1 deletion sqlx-core/src/mssql/column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Column for MssqlColumn {
}

fn name(&self) -> &str {
&*self.name
&self.name
}

fn type_info(&self) -> &MssqlTypeInfo {
Expand Down
Loading
Loading