diff --git a/sqlx-core/src/row.rs b/sqlx-core/src/row.rs index bae78b25..4fc31328 100644 --- a/sqlx-core/src/row.rs +++ b/sqlx-core/src/row.rs @@ -31,7 +31,7 @@ where impl<'c, R, I> ColumnIndex<'c, R> for &'_ I where R: Row<'c>, - I: ColumnIndex<'c, R>, + I: ColumnIndex<'c, R> + ?Sized, { #[inline] fn index(&self, row: &R) -> crate::Result<>::Database, usize> { @@ -44,7 +44,7 @@ mod private_column_index { pub trait Sealed {} impl Sealed for usize {} impl Sealed for str {} - impl Sealed for &'_ T where T: Sealed {} + impl Sealed for &'_ T where T: Sealed + ?Sized {} } /// Represents a single row from the database. diff --git a/sqlx-macros/src/derives/row.rs b/sqlx-macros/src/derives/row.rs index bf2f0767..0dd47cba 100644 --- a/sqlx-macros/src/derives/row.rs +++ b/sqlx-macros/src/derives/row.rs @@ -86,7 +86,7 @@ fn expand_derive_from_row_struct( Ok(quote!( impl #impl_generics sqlx::row::FromRow<#lifetime, R> for #ident #ty_generics #where_clause { - fn from_row(row: R) -> sqlx::Result { + fn from_row(row: &R) -> sqlx::Result { #(#reads)* Ok(#ident { diff --git a/tests/postgres-derives.rs b/tests/postgres-derives.rs index 2ecfa8aa..3cd4a664 100644 --- a/tests/postgres-derives.rs +++ b/tests/postgres-derives.rs @@ -125,7 +125,7 @@ async fn test_from_row() -> anyhow::Result<()> { .bind(1_i32) .fetch(&mut conn); - let account = RefAccount::from_row(cursor.next().await?.unwrap())?; + let account = RefAccount::from_row(&cursor.next().await?.unwrap())?; assert_eq!(account.id, 1); assert_eq!(account.name, "Herp Derpinson");