From c5f3513f7de4a73dea545f715c35f2b84908cbef Mon Sep 17 00:00:00 2001 From: RustyYato Date: Fri, 2 Sep 2022 17:52:05 -0700 Subject: [PATCH] Fix expansion of `sqlx(flatten)` (#2023) Given a generic type like `A` before `sqlx` would produce `A::from_row(row)` which is invalid syntax. Now it produces ` as ::sqlx::FromRow<'a, R>>`. This also fixes a bug for non-generic types where an inherent method might have been called instead of the `::sqlx::FromRow::from_row` method because UFCS wasn't used. --- sqlx-macros/src/derives/row.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sqlx-macros/src/derives/row.rs b/sqlx-macros/src/derives/row.rs index f1d92c37..e0c997d5 100644 --- a/sqlx-macros/src/derives/row.rs +++ b/sqlx-macros/src/derives/row.rs @@ -74,7 +74,7 @@ fn expand_derive_from_row_struct( let expr: Expr = if attributes.flatten { predicates.push(parse_quote!(#ty: ::sqlx::FromRow<#lifetime, R>)); - parse_quote!(#ty::from_row(row)) + parse_quote!(<#ty as ::sqlx::FromRow<#lifetime, R>>::from_row(row)) } else { predicates.push(parse_quote!(#ty: ::sqlx::decode::Decode<#lifetime, R::Database>)); predicates.push(parse_quote!(#ty: ::sqlx::types::Type));