From 4d27f8527f811ad4a269eb805085dbc94b958a09 Mon Sep 17 00:00:00 2001 From: lovasoa Date: Fri, 16 Aug 2024 11:47:35 +0200 Subject: [PATCH] clippy fixes --- test.sh | 4 ++-- tests/postgres/macros.rs | 4 ++-- tests/postgres/postgres.rs | 8 +++----- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/test.sh b/test.sh index 8d3c9e77c2..76632d0080 100755 --- a/test.sh +++ b/test.sh @@ -1,6 +1,6 @@ #!/bin/sh -docker-compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_16 postgres_16 +docker compose -f tests/docker-compose.yml run -d -p 5432:5432 --name postgres_16 postgres_16 DATABASE_URL="postgres://postgres@localhost:5432/sqlx?sslmode=verify-ca&sslrootcert=./tests/certs/ca.crt&sslcert=./tests/certs/client.crt&sslkey=./tests/keys/client.key" cargo test --features any,postgres,macros,all-types,runtime-actix-rustls -- -docker-compose -f tests/docker-compose.yml run -d -p 1433:1433 --name mssql_2022 mssql_2022 +docker compose -f tests/docker-compose.yml run -d -p 1433:1433 --name mssql_2022 mssql_2022 DATABASE_URL='mssql://sa:Password123!@localhost/sqlx' cargo test --features any,mssql,macros,all-types,runtime-actix-rustls -- \ No newline at end of file diff --git a/tests/postgres/macros.rs b/tests/postgres/macros.rs index 6b4345033b..3eb0c36ba5 100644 --- a/tests/postgres/macros.rs +++ b/tests/postgres/macros.rs @@ -254,7 +254,7 @@ async fn query_by_string() -> anyhow::Result<()> { let mut conn = new::().await?; let string = "Hello, world!".to_string(); - let ref tuple = ("Hello, world!".to_string(),); + let tuple = &("Hello, world!".to_string(),); let result = sqlx_oldapi::query!( "SELECT * from (VALUES('Hello, world!')) strings(string)\ @@ -284,7 +284,7 @@ async fn query_by_bigdecimal() -> anyhow::Result<()> { // this tests querying by a non-`Copy` type that doesn't have special reborrow semantics let decimal = "1234".parse::()?; - let ref tuple = ("51245.121232".parse::()?,); + let tuple = &("51245.121232".parse::()?,); let result = sqlx_oldapi::query!( "SELECT * from (VALUES(1234.0)) decimals(decimal)\ diff --git a/tests/postgres/postgres.rs b/tests/postgres/postgres.rs index 1a1e36bfff..d92ba0abc9 100644 --- a/tests/postgres/postgres.rs +++ b/tests/postgres/postgres.rs @@ -1,5 +1,4 @@ use futures::{StreamExt, TryStreamExt}; -use sqlx_core::postgres::PgArguments; use sqlx_oldapi::postgres::types::Oid; use sqlx_oldapi::postgres::{ PgAdvisoryLock, PgConnectOptions, PgConnection, PgDatabaseError, PgErrorPosition, PgListener, @@ -10,7 +9,6 @@ use sqlx_test::{new, pool, setup_if_needed}; use std::env; use std::sync::Arc; use std::time::Duration; -use tokio::time::error::Elapsed; #[sqlx_macros::test] async fn it_connects() -> anyhow::Result<()> { @@ -1540,12 +1538,12 @@ async fn it_encodes_custom_array_issue_1504() -> anyhow::Result<()> { Ok(Self::Number(n)) } else if typ == PgTypeInfo::with_name("_text") { let arr = Vec::::decode(value)?; - let v = arr.into_iter().map(|s| Value::String(s)).collect(); + let v = arr.into_iter().map(Value::String).collect(); Ok(Self::Array(v)) } else if typ == PgTypeInfo::with_name("_int4") { let arr = Vec::::decode(value)?; - let v = arr.into_iter().map(|n| Value::Number(n)).collect(); + let v = arr.into_iter().map(Value::Number).collect(); Ok(Self::Array(v)) } else { @@ -1558,7 +1556,7 @@ async fn it_encodes_custom_array_issue_1504() -> anyhow::Result<()> { fn produces(&self) -> Option { match self { Self::Array(a) => { - if a.len() < 1 { + if a.is_empty() { return Some(PgTypeInfo::with_name("_text")); }