FromRow -> FromSqlRow

This commit is contained in:
Ryan Leckey 2019-08-20 21:42:25 -07:00
parent b33bc3c017
commit 99e4d200b2
6 changed files with 30 additions and 30 deletions

View File

@ -1,4 +1,4 @@
use crate::{backend::Backend, executor::Executor, query::RawQuery, row::FromRow};
use crate::{backend::Backend, executor::Executor, query::RawQuery, row::FromSqlRow};
use crossbeam_queue::SegQueue;
use crossbeam_utils::atomic::AtomicCell;
use futures_channel::oneshot::{channel, Sender};
@ -98,7 +98,7 @@ where
fn fetch<'c, 'q, T: 'c, Q: 'q + 'c>(&'c self, query: Q) -> BoxStream<'c, io::Result<T>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend> + Send + Unpin,
T: FromSqlRow<Self::Backend> + Send + Unpin,
{
Box::pin(async_stream::try_stream! {
let mut conn = self.get().await;
@ -116,7 +116,7 @@ where
) -> BoxFuture<'c, io::Result<Option<T>>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend>,
T: FromSqlRow<Self::Backend>,
{
Box::pin(async move {
let mut conn = self.get().await;

View File

@ -1,4 +1,4 @@
use crate::{backend::Backend, query::RawQuery, row::FromRow};
use crate::{backend::Backend, query::RawQuery, row::FromSqlRow};
use futures_core::{future::BoxFuture, stream::BoxStream};
use std::io;
@ -12,7 +12,7 @@ pub trait Executor: Send {
fn fetch<'c, 'q, T: 'c, Q: 'q + 'c>(&'c self, query: Q) -> BoxStream<'c, io::Result<T>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend> + Send + Unpin;
T: FromSqlRow<Self::Backend> + Send + Unpin;
fn fetch_optional<'c, 'q, T: 'c, Q: 'q + 'c>(
&'c self,
@ -20,7 +20,7 @@ pub trait Executor: Send {
) -> BoxFuture<'c, io::Result<Option<T>>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend>;
T: FromSqlRow<Self::Backend>;
}
impl<'e, E> Executor for &'e E
@ -40,7 +40,7 @@ where
fn fetch<'c, 'q, T: 'c, Q: 'q + 'c>(&'c self, query: Q) -> BoxStream<'c, io::Result<T>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend> + Send + Unpin,
T: FromSqlRow<Self::Backend> + Send + Unpin,
{
(*self).fetch(query)
}
@ -51,7 +51,7 @@ where
) -> BoxFuture<'c, io::Result<Option<T>>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend>,
T: FromSqlRow<Self::Backend>,
{
(*self).fetch_optional(query)
}

View File

@ -11,5 +11,5 @@ impl Backend for Pg {
type Row = super::PgRow;
}
// Generates tuple FromRow impls for this backend
impl_from_row_tuples_for_backend!(Pg);
// Generates tuple FromSqlRow impls for this backend
impl_from_sql_row_tuples_for_backend!(Pg);

View File

@ -1,5 +1,5 @@
use crate::{
backend::Backend, connection::RawConnection, executor::Executor, query::RawQuery, row::FromRow,
backend::Backend, connection::RawConnection, executor::Executor, query::RawQuery, row::FromSqlRow,
};
use crossbeam_queue::{ArrayQueue, SegQueue};
use futures_channel::oneshot;
@ -143,7 +143,7 @@ where
fn fetch<'c, 'q, T: 'c, Q: 'q + 'c>(&'c self, query: Q) -> BoxStream<'c, io::Result<T>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend> + Send + Unpin,
T: FromSqlRow<Self::Backend> + Send + Unpin,
{
Box::pin(async_stream::try_stream! {
let live = self.0.acquire().await?;
@ -162,7 +162,7 @@ where
) -> BoxFuture<'c, io::Result<Option<T>>>
where
Q: RawQuery<'q, Backend = Self::Backend>,
T: FromRow<Self::Backend>,
T: FromSqlRow<Self::Backend>,
{
Box::pin(async move {
let live = self.0.acquire().await?;

View File

@ -1,7 +1,7 @@
use crate::{
backend::{Backend, BackendAssocRawQuery},
executor::Executor,
row::FromRow,
row::FromSqlRow,
serialize::ToSql,
types::HasSqlType,
};
@ -64,7 +64,7 @@ where
pub fn fetch<E, T: 'q>(self, executor: &'q E) -> BoxStream<'q, io::Result<T>>
where
E: Executor<Backend = DB>,
T: FromRow<DB> + Send + Unpin,
T: FromSqlRow<DB> + Send + Unpin,
<DB as BackendAssocRawQuery<'q, DB>>::RawQuery: 'q,
{
executor.fetch(self.inner)
@ -74,7 +74,7 @@ where
pub fn fetch_optional<E, T: 'q>(self, executor: &'q E) -> BoxFuture<'q, io::Result<Option<T>>>
where
E: Executor<Backend = DB>,
T: FromRow<DB>,
T: FromSqlRow<DB>,
<DB as BackendAssocRawQuery<'q, DB>>::RawQuery: 'q,
{
executor.fetch_optional(self.inner)

View File

@ -19,11 +19,11 @@ pub trait Row: Send {
}
}
pub trait FromRow<DB: Backend> {
pub trait FromSqlRow<DB: Backend> {
fn from_row<R: Row<Backend = DB>>(row: R) -> Self;
}
impl<T, DB> FromRow<DB> for T
impl<T, DB> FromSqlRow<DB> for T
where
DB: Backend + HasSqlType<T>,
T: FromSql<DB>,
@ -35,9 +35,9 @@ where
}
#[allow(unused)]
macro_rules! impl_from_row_tuple {
macro_rules! impl_from_sql_row_tuple {
($B:ident: $( ($idx:tt) -> $T:ident );+;) => {
impl<$($T,)+> crate::row::FromRow<$B> for ($($T,)+)
impl<$($T,)+> crate::row::FromSqlRow<$B> for ($($T,)+)
where
$($B: crate::types::HasSqlType<$T>,)+
$($T: crate::deserialize::FromSql<$B>,)+
@ -51,31 +51,31 @@ macro_rules! impl_from_row_tuple {
}
#[allow(unused)]
macro_rules! impl_from_row_tuples_for_backend {
macro_rules! impl_from_sql_row_tuples_for_backend {
($B:ident) => {
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;
(3) -> T4;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;
@ -83,7 +83,7 @@ macro_rules! impl_from_row_tuples_for_backend {
(4) -> T5;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;
@ -92,7 +92,7 @@ macro_rules! impl_from_row_tuples_for_backend {
(5) -> T6;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;
@ -102,7 +102,7 @@ macro_rules! impl_from_row_tuples_for_backend {
(6) -> T7;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;
@ -113,7 +113,7 @@ macro_rules! impl_from_row_tuples_for_backend {
(7) -> T8;
);
impl_from_row_tuple!($B:
impl_from_sql_row_tuple!($B:
(0) -> T1;
(1) -> T2;
(2) -> T3;