From e97e444417c5f4efcbea7fbee9e652734e23e0be Mon Sep 17 00:00:00 2001 From: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> Date: Sun, 31 May 2026 20:23:21 +0700 Subject: [PATCH 1/4] =?UTF-8?q?fix:=20resolve=20#4284=20=E2=80=94=20Claude?= =?UTF-8?q?=20Code=20Review=20Report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4284 Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> --- sqlx-core/src/any/arguments.rs | 47 ++++++++++++++++++++++++++++++++-- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/sqlx-core/src/any/arguments.rs b/sqlx-core/src/any/arguments.rs index 59d6f4d6e0..4d74f35a64 100644 --- a/sqlx-core/src/any/arguments.rs +++ b/sqlx-core/src/any/arguments.rs @@ -67,8 +67,8 @@ impl AnyArguments { AnyValueKind::Null(AnyTypeInfoKind::SmallInt) => out.add(Option::::None), AnyValueKind::Null(AnyTypeInfoKind::Integer) => out.add(Option::::None), AnyValueKind::Null(AnyTypeInfoKind::BigInt) => out.add(Option::::None), - AnyValueKind::Null(AnyTypeInfoKind::Real) => out.add(Option::::None), - AnyValueKind::Null(AnyTypeInfoKind::Double) => out.add(Option::::None), + AnyValueKind::Null(AnyTypeInfoKind::Real) => out.add(Option::::None), + AnyValueKind::Null(AnyTypeInfoKind::Double) => out.add(Option::::None), AnyValueKind::Null(AnyTypeInfoKind::Text) => out.add(Option::::None), AnyValueKind::Null(AnyTypeInfoKind::Blob) => out.add(Option::>::None), AnyValueKind::Bool(b) => out.add(b), @@ -85,3 +85,46 @@ impl AnyArguments { Ok(out) } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn convert_into_maps_null_real_to_f32_and_null_double_to_f64() { + let mut args = AnyArguments::default(); + args.values.0.push(AnyValueKind::Null(AnyTypeInfoKind::Real)); + args.values.0.push(AnyValueKind::Null(AnyTypeInfoKind::Double)); + + let out: AnyArguments = args.convert_into().unwrap(); + + assert_eq!(out.values.0.len(), 2); + assert!(matches!( + out.values.0[0], + AnyValueKind::Null(AnyTypeInfoKind::Real) + )); + assert!(matches!( + out.values.0[1], + AnyValueKind::Null(AnyTypeInfoKind::Double) + )); + } + + #[test] + fn convert_into_preserves_non_float_null_types() { + let mut args = AnyArguments::default(); + args.values.0.push(AnyValueKind::Null(AnyTypeInfoKind::Integer)); + args.values.0.push(AnyValueKind::Null(AnyTypeInfoKind::BigInt)); + + let out: AnyArguments = args.convert_into().unwrap(); + + assert_eq!(out.values.0.len(), 2); + assert!(matches!( + out.values.0[0], + AnyValueKind::Null(AnyTypeInfoKind::Integer) + )); + assert!(matches!( + out.values.0[1], + AnyValueKind::Null(AnyTypeInfoKind::BigInt) + )); + } +} From f895930aeee7f9bc0d51fc806625768b3a83df3d Mon Sep 17 00:00:00 2001 From: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> Date: Sun, 31 May 2026 20:23:23 +0700 Subject: [PATCH 2/4] =?UTF-8?q?fix:=20resolve=20#4284=20=E2=80=94=20Claude?= =?UTF-8?q?=20Code=20Review=20Report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4284 Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> --- sqlx-core/src/any/connection/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-core/src/any/connection/mod.rs b/sqlx-core/src/any/connection/mod.rs index 894b109ccd..44a26f2fb3 100644 --- a/sqlx-core/src/any/connection/mod.rs +++ b/sqlx-core/src/any/connection/mod.rs @@ -101,7 +101,7 @@ impl Connection for AnyConnection { } fn close_hard(self) -> impl Future> + Send + 'static { - self.backend.close() + self.backend.close_hard() } fn ping(&mut self) -> impl Future> + Send + '_ { From 0ee0cca44ab09eb644373bc9a8cfd5eceb4e724f Mon Sep 17 00:00:00 2001 From: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> Date: Sun, 31 May 2026 20:23:25 +0700 Subject: [PATCH 3/4] =?UTF-8?q?fix:=20resolve=20#4284=20=E2=80=94=20Claude?= =?UTF-8?q?=20Code=20Review=20Report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4284 Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> --- sqlx-sqlite/src/logger.rs | 39 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/sqlx-sqlite/src/logger.rs b/sqlx-sqlite/src/logger.rs index 1464a730c7..4f0e7dfbfa 100644 --- a/sqlx-sqlite/src/logger.rs +++ b/sqlx-sqlite/src/logger.rs @@ -59,6 +59,43 @@ fn dot_escape_string(value: impl AsRef) -> String { .to_string() } +#[cfg(test)] +mod tests { + use super::*; + use crate::connection::intmap::IntMap; + use std::collections::HashSet; + + #[derive(Debug)] + struct TestState; + + impl DebugDiff for TestState { + fn diff(&self, _prev: &Self) -> String { + String::new() + } + } + + #[test] + fn max_branch_id_includes_branch_origins() { + let program: &[&str] = &["Init"]; + let mut logger: QueryPlanLogger<'_, i64, TestState, &str> = QueryPlanLogger { + sql: "SELECT 1", + unknown_operations: HashSet::new(), + branch_origins: IntMap::new(), + branch_results: IntMap::new(), + branch_operations: IntMap::new(), + program, + }; + + logger + .branch_origins + .insert(7, BranchParent { id: 0, idx: 0 }); + + let rendered = logger.to_string(); + + assert!(rendered.contains('7')); + } +} + impl core::fmt::Display for QueryPlanLogger<'_, R, S, P> { fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { //writes query plan history in dot format @@ -224,7 +261,7 @@ impl core::fmt::Display for QueryPlanL let max_branch_id: i64 = [ self.branch_operations.last_index().unwrap_or(0), self.branch_results.last_index().unwrap_or(0), - self.branch_results.last_index().unwrap_or(0), + self.branch_origins.last_index().unwrap_or(0), ] .into_iter() .max() From d31b864bf666e8b3fb13505859fec41d9cec26a8 Mon Sep 17 00:00:00 2001 From: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> Date: Sun, 31 May 2026 20:23:26 +0700 Subject: [PATCH 4/4] =?UTF-8?q?fix:=20resolve=20#4284=20=E2=80=94=20Claude?= =?UTF-8?q?=20Code=20Review=20Report?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixes #4284 Signed-off-by: ChinhLee <76194645+chinhkrb113@users.noreply.github.com> --- sqlx-macros-core/src/query/metadata.rs | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sqlx-macros-core/src/query/metadata.rs b/sqlx-macros-core/src/query/metadata.rs index b3b31c0eb5..4d5bc3fa16 100644 --- a/sqlx-macros-core/src/query/metadata.rs +++ b/sqlx-macros-core/src/query/metadata.rs @@ -156,7 +156,33 @@ fn load_env( })) } -/// Returns `true` if `val` is `"true"`, +/// Returns `true` if `val` is `"true"` (case-insensitive) or `"1"`. fn is_truthy_bool(val: &str) -> bool { val.eq_ignore_ascii_case("true") || val == "1" } + +#[cfg(test)] +mod tests { + use super::is_truthy_bool; + + #[test] + fn truthy_values_return_true() { + assert!(is_truthy_bool("true")); + assert!(is_truthy_bool("1")); + } + + #[test] + fn truthy_is_case_insensitive() { + assert!(is_truthy_bool("TRUE")); + assert!(is_truthy_bool("True")); + assert!(is_truthy_bool("tRuE")); + } + + #[test] + fn falsy_values_return_false() { + assert!(!is_truthy_bool("false")); + assert!(!is_truthy_bool("0")); + assert!(!is_truthy_bool("")); + assert!(!is_truthy_bool("yes")); + } +}