pub struct MockDb<'a> { /* private fields */ }
Expand description
The implementation collects all SQL statements that can be asserted. For loading it return default values.
Implementations
sourceimpl<'a> MockDb<'a>
impl<'a> MockDb<'a>
pub fn clear_rows(&mut self)
pub fn reset_id(&mut self)
pub fn take_unsafe_sqls(&mut self) -> Vec<String>
pub fn take_unsafe_sql(&mut self) -> String
pub fn sqls_empty(&mut self) -> bool
pub fn mock_rows(&mut self, select: impl Into<String>, rows: Vec<Row>)
Trait Implementations
sourceimpl<'a> ToqlApi for MockDb<'a>
impl<'a> ToqlApi for MockDb<'a>
sourcefn insert_many<'life0, 'life1, 'async_trait, T, Q>(
&'life0 mut self,
entities: &'life1 mut [Q],
paths: Paths
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
T: Insert,
Q: BorrowMut<T> + Send,
T: 'async_trait,
Q: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn insert_many<'life0, 'life1, 'async_trait, T, Q>(
&'life0 mut self,
entities: &'life1 mut [Q],
paths: Paths
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
T: Insert,
Q: BorrowMut<T> + Send,
T: 'async_trait,
Q: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
Insert one struct.
Skip fields in struct that are auto generated with #[toql(skip_inup)]
.
Returns the last generated id.
sourcefn load_one<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<T, Self::Error>> + Send + 'async_trait>> where
T: Load<Self::Row, Self::Error>,
B: Borrow<Query<T>> + Send + Sync,
<T as Keyed>::Key: FromRow<Self::Row, Self::Error>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn load_one<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<T, Self::Error>> + Send + 'async_trait>> where
T: Load<Self::Row, Self::Error>,
B: Borrow<Query<T>> + Send + Sync,
<T as Keyed>::Key: FromRow<Self::Row, Self::Error>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Load a struct with dependencies for a given Toql query.
Returns a struct or a ToqlMySqlAsyncError if no struct was found NotFound or more than one NotUnique.
sourcefn load_many<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Self::Error>> + Send + 'async_trait>> where
T: Load<Self::Row, Self::Error>,
B: Borrow<Query<T>> + Send + Sync,
<T as Keyed>::Key: FromRow<Self::Row, Self::Error>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn load_many<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<Vec<T>, Self::Error>> + Send + 'async_trait>> where
T: Load<Self::Row, Self::Error>,
B: Borrow<Query<T>> + Send + Sync,
<T as Keyed>::Key: FromRow<Self::Row, Self::Error>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Load a vector of structs with dependencies for a given Toql query.
Returns a tuple with the structs and an optional tuple of count values.
If count
argument is false
, no count queries are run and the resulting Option<(u32,u32)>
will be None
otherwise the count queries are run and it will be Some((total count, filtered count))
.
sourcefn load_page<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B,
page: Page
) -> Pin<Box<dyn Future<Output = Result<(Vec<T>, Option<PageCounts>), Self::Error>> + Send + 'async_trait>> where
T: Load<Self::Row, Self::Error>,
B: Borrow<Query<T>> + Send + Sync,
<T as Keyed>::Key: FromRow<Self::Row, Self::Error>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn load_page<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B,
page: Page
) -> Pin<Box<dyn Future<Output = Result<(Vec<T>, Option<PageCounts>), Self::Error>> + Send + 'async_trait>> where
T: Load<Self::Row, Self::Error>,
B: Borrow<Query<T>> + Send + Sync,
<T as Keyed>::Key: FromRow<Self::Row, Self::Error>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Load a vector of structs with dependencies for a given Toql query.
Returns a tuple with the structs and an optional tuple of count values.
If count
argument is false
, no count queries are run and the resulting Option<(u32,u32)>
will be None
otherwise the count queries are run and it will be Some((unpaged count, unfiltered count))
.
sourcefn count<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>> where
T: Count,
B: Borrow<Query<T>> + Send + Sync,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn count<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<u64, Self::Error>> + Send + 'async_trait>> where
T: Count,
B: Borrow<Query<T>> + Send + Sync,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Counts the number of rows that match the query predicate.
Returns a struct or a ToqlMySqlAsyncError if no struct was found NotFound or more than one NotUnique.
type Row = Row
type Error = ToqlError
fn insert_one<'life0, 'life1, 'async_trait, T>(
&'life0 mut self,
entity: &'life1 mut T,
paths: Paths
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
T: Insert,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn update_one<'life0, 'life1, 'async_trait, T>(
&'life0 mut self,
entity: &'life1 mut T,
fields: Fields
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
T: Update + Keyed,
T: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn update_many<'life0, 'life1, 'async_trait, T, Q>(
&'life0 mut self,
entities: &'life1 mut [Q],
fields: Fields
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
T: Update + Keyed,
Q: BorrowMut<T> + Send + Sync,
T: 'async_trait,
Q: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn delete_one<'life0, 'async_trait, K>(
&'life0 mut self,
key: K
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
K: Key + Into<Query<<K as Key>::Entity>> + Send,
<K as Key>::Entity: Send + Delete,
K: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
fn delete_many<'life0, 'async_trait, T, B>(
&'life0 mut self,
query: B
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>> where
T: Delete,
B: Borrow<Query<T>> + Send + Sync,
<Self as ToqlApi>::Error: From<ToqlError>,
T: 'async_trait,
B: 'async_trait,
'life0: 'async_trait,
Self: 'async_trait,
Auto Trait Implementations
impl<'a> RefUnwindSafe for MockDb<'a>
impl<'a> Send for MockDb<'a>
impl<'a> Sync for MockDb<'a>
impl<'a> Unpin for MockDb<'a>
impl<'a> UnwindSafe for MockDb<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more