mirror of
https://github.com/launchbadge/sqlx
synced 2024-11-10 06:24:16 +00:00
fix FromRow derive to take &Row
This commit is contained in:
parent
e71b969e78
commit
dcea3f0586
3 changed files with 4 additions and 4 deletions
|
@ -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<<R as Row<'c>>::Database, usize> {
|
||||
|
@ -44,7 +44,7 @@ mod private_column_index {
|
|||
pub trait Sealed {}
|
||||
impl Sealed for usize {}
|
||||
impl Sealed for str {}
|
||||
impl<T> Sealed for &'_ T where T: Sealed {}
|
||||
impl<T> Sealed for &'_ T where T: Sealed + ?Sized {}
|
||||
}
|
||||
|
||||
/// Represents a single row from the database.
|
||||
|
|
|
@ -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<R::Database, Self> {
|
||||
fn from_row(row: &R) -> sqlx::Result<R::Database, Self> {
|
||||
#(#reads)*
|
||||
|
||||
Ok(#ident {
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue