| 1 |
use crate::expression::Expression; |
| 2 |
use crate::query_source::Table; |
| 3 |
|
| 4 |
/// The `select` method |
| 5 |
/// |
| 6 |
/// This trait should not be relied on directly by most apps. Its behavior is |
| 7 |
/// provided by [`QueryDsl`]. However, you may need a where clause on this trait |
| 8 |
/// to call `select` from generic code. |
| 9 |
/// |
| 10 |
/// [`QueryDsl`]: crate::QueryDsl |
| 11 |
pub trait SelectDsl<Selection: Expression> { |
| 12 |
// FIXME: Once we've refactored the `impl Expression` on `SelectStatement` |
| 13 |
// to not conditionally be `sql_types::Array`, it is probably worthwhile to |
| 14 |
// add a `: Expression<SqlType = Selection::SqlType>` bound here. |
| 15 |
/// The type returned by `.select` |
| 16 |
type Output; |
| 17 |
|
| 18 |
/// See the trait documentation |
| 19 |
fn select(self, selection: Selection) -> Self::Output; |
| 20 |
} |
| 21 |
|
| 22 |
impl<T, Selection> SelectDsl<Selection> for T |
| 23 |
where |
| 24 |
Selection: Expression, |
| 25 |
T: Table, |
| 26 |
T::Query: SelectDsl<Selection>, |
| 27 |
{ |
| 28 |
type Output = <T::Query as SelectDsl<Selection>>::Output; |
| 29 |
|
| 30 |
fn select(self, selection: Selection) -> Self::Output { |
| 31 |
self.as_query().select(selection) |
| 32 |
} |
| 33 |
} |