Skip to content

Commit

Permalink
fix: non snake case warning (#3454)
Browse files Browse the repository at this point in the history
* fix: non-snake-case fields warning

* cargo fmt
  • Loading branch information
joeydewaal authored Aug 25, 2024
1 parent f69f370 commit 018ffe7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
1 change: 1 addition & 0 deletions sqlx-macros-core/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ where

let mut record_tokens = quote! {
#[derive(Debug)]
#[allow(non_snake_case)]
struct #record_name {
#(#record_fields)*
}
Expand Down
16 changes: 13 additions & 3 deletions sqlx-macros-core/src/query/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)?;
),
}
},
);
Expand Down

0 comments on commit 018ffe7

Please sign in to comment.