fix: non snake case warning (#3454)

* fix: non-snake-case fields warning

* cargo fmt
This commit is contained in:
joeydewaal 2024-08-25 04:24:53 +02:00 committed by GitHub
parent f69f370f25
commit 018ffe7e0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 14 additions and 3 deletions

View File

@ -301,6 +301,7 @@ where
let mut record_tokens = quote! {
#[derive(Debug)]
#[allow(non_snake_case)]
struct #record_name {
#(#record_fields)*
}

View File

@ -143,15 +143,25 @@ pub fn quote_query_as<DB: DatabaseExt>(
// 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)?;
),
}
},
);