Merge pull request #18 from FlixCoder/patch-1

Document the macro-generated static
This commit is contained in:
Diggory Blake 2022-01-13 23:31:08 +00:00 committed by GitHub
commit 6d3ed6fb99
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 1 deletions

View file

@ -231,6 +231,11 @@ pub fn job(attr: TokenStream, item: TokenStream) -> TokenStream {
}
}
let outer_docs = inner_fn
.attrs
.iter()
.filter(|attr| attr.path.is_ident("doc"));
let vis = mem::replace(&mut inner_fn.vis, Visibility::Inherited);
let name = mem::replace(&mut inner_fn.sig.ident, parse_quote! {inner});
let fq_name = if let Some(name) = options.name {
@ -281,6 +286,7 @@ pub fn job(attr: TokenStream, item: TokenStream) -> TokenStream {
let expanded = quote! {
#(#errors)*
#(#outer_docs)*
#[allow(non_upper_case_globals)]
#vis static #name: &'static sqlxmq::NamedJob = &{
#inner_fn

View file

@ -242,7 +242,7 @@ pub fn should_retry(error: &sqlx::Error) -> bool {
if let Some(db_error) = error.as_database_error() {
// It's more readable as a match
#[allow(clippy::match_like_matches_macro)]
match (db_error.code().as_deref(), db_error.constraint().as_deref()) {
match (db_error.code().as_deref(), db_error.constraint()) {
// Foreign key constraint violation on ordered channel
(Some("23503"), Some("mq_msgs_after_message_id_fkey")) => true,
// Unique constraint violation on ordered channel