Refactor
This commit is contained in:
parent
99a1fe01fc
commit
007d27768d
@ -91,10 +91,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E> Select<E>
|
macro_rules! select_query {
|
||||||
where
|
() => {
|
||||||
E: EntityTrait,
|
|
||||||
{
|
|
||||||
/// Get a mutable ref to the query builder
|
/// Get a mutable ref to the query builder
|
||||||
pub fn query(&mut self) -> &mut SelectStatement {
|
pub fn query(&mut self) -> &mut SelectStatement {
|
||||||
&mut self.query
|
&mut self.query
|
||||||
@ -117,6 +115,14 @@ where
|
|||||||
{
|
{
|
||||||
self.as_query().build(builder).into()
|
self.as_query().build(builder).into()
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<E> Select<E>
|
||||||
|
where
|
||||||
|
E: EntityTrait,
|
||||||
|
{
|
||||||
|
select_query!();
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<E, F> SelectTwo<E, F>
|
impl<E, F> SelectTwo<E, F>
|
||||||
@ -124,26 +130,5 @@ where
|
|||||||
E: EntityTrait,
|
E: EntityTrait,
|
||||||
F: EntityTrait,
|
F: EntityTrait,
|
||||||
{
|
{
|
||||||
/// Get a mutable ref to the query builder
|
select_query!();
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user