This commit is contained in:
Chris Tsang 2021-05-27 02:31:47 +08:00
parent 99a1fe01fc
commit 007d27768d

View File

@ -91,10 +91,8 @@ where
}
}
impl<E> Select<E>
where
E: EntityTrait,
{
macro_rules! select_query {
() => {
/// Get a mutable ref to the query builder
pub fn query(&mut self) -> &mut SelectStatement {
&mut self.query
@ -117,6 +115,14 @@ where
{
self.as_query().build(builder).into()
}
};
}
impl<E> Select<E>
where
E: EntityTrait,
{
select_query!();
}
impl<E, F> SelectTwo<E, F>
@ -124,26 +130,5 @@ where
E: EntityTrait,
F: EntityTrait,
{
/// Get a mutable ref to the query builder
pub fn query(&mut self) -> &mut SelectStatement {
&mut self.query
}
/// Get an immutable ref to the query builder
pub fn as_query(&self) -> &SelectStatement {
&self.query
}
/// Take ownership of the query builder
pub fn into_query(self) -> SelectStatement {
self.query
}
/// Build the query as [`Statement`]
pub fn build<B>(&self, builder: B) -> Statement
where
B: QueryBuilder,
{
self.as_query().build(builder).into()
}
select_query!();
}