From 018ffe7e0d8d4f2fbc75b75ef80048fa31dd4139 Mon Sep 17 00:00:00 2001 From: joeydewaal <99046430+joeydewaal@users.noreply.github.com> Date: Sun, 25 Aug 2024 04:24:53 +0200 Subject: [PATCH] fix: non snake case warning (#3454) * fix: non-snake-case fields warning * cargo fmt --- sqlx-macros-core/src/query/mod.rs | 1 + sqlx-macros-core/src/query/output.rs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sqlx-macros-core/src/query/mod.rs b/sqlx-macros-core/src/query/mod.rs index 1536eeba..09acff9b 100644 --- a/sqlx-macros-core/src/query/mod.rs +++ b/sqlx-macros-core/src/query/mod.rs @@ -301,6 +301,7 @@ where let mut record_tokens = quote! { #[derive(Debug)] + #[allow(non_snake_case)] struct #record_name { #(#record_fields)* } diff --git a/sqlx-macros-core/src/query/output.rs b/sqlx-macros-core/src/query/output.rs index 596a52e8..5e7cc505 100644 --- a/sqlx-macros-core/src/query/output.rs +++ b/sqlx-macros-core/src/query/output.rs @@ -143,15 +143,25 @@ pub fn quote_query_as( // binding to a `let` avoids confusing errors about // "try expression alternatives have incompatible types" // it doesn't seem to hurt inference in the other branches + #[allow(non_snake_case)] let #var_name = row.try_get_unchecked::<#type_, _>(#i)?.into(); }, // type was overridden to be a wildcard so we fallback to the runtime check - (true, ColumnType::Wildcard) => quote! ( let #var_name = row.try_get(#i)?; ), + (true, ColumnType::Wildcard) => quote! ( + #[allow(non_snake_case)] + let #var_name = row.try_get(#i)?; + ), (true, ColumnType::OptWildcard) => { - quote! ( let #var_name = row.try_get::<::std::option::Option<_>, _>(#i)?; ) + quote! ( + #[allow(non_snake_case)] + let #var_name = row.try_get::<::std::option::Option<_>, _>(#i)?; + ) } // macro is the `_unchecked!()` variant so this will die in decoding if it's wrong - (false, _) => quote!( let #var_name = row.try_get_unchecked(#i)?; ), + (false, _) => quote!( + #[allow(non_snake_case)] + let #var_name = row.try_get_unchecked(#i)?; + ), } }, );