diesel/query_source/aliasing/
mod.rs

1//! Everything related to table aliasing
2//!
3//! See [`alias!`](crate::alias!) for more details
4
5mod alias;
6mod aliased_field;
7mod dsl_impls;
8mod field_alias_mapper;
9mod joins;
10mod macros;
11
12// This is reexported from the parent module
13#[allow(unreachable_pub)]
14pub use alias::Alias;
15// This is reexported from the parent module
16#[allow(unreachable_pub)]
17#[doc(hidden)] // This is used by the table macro
18pub use alias::{
19    AliasAliasAppearsInFromClause, AliasAliasAppearsInFromClauseSameTable, AliasAppearsInFromClause,
20};
21#[allow(unreachable_pub)]
22pub use aliased_field::AliasedField;
23#[allow(unreachable_pub)]
24#[doc(hidden)] // This is used by the table macro
25pub use field_alias_mapper::{FieldAliasMapper, FieldAliasMapperAssociatedTypesDisjointnessTrick};
26
27pub(crate) use alias::GetAliasSourceFromAlias;
28
29/// Types created by the `alias!` macro that serve to distinguish between aliases implement
30/// this trait.
31///
32/// In order to be able to implement within diesel a lot of traits on what will represent the alias,
33/// we cannot use directly that new type within the query builder. Instead, we will use `Alias<S>`,
34/// where `S: AliasSource`.
35///
36/// This trait should never be implemented by an end-user directly.
37pub trait AliasSource {
38    /// The name of this alias in the query
39    const NAME: &'static str;
40    /// The table the alias maps to
41    type Target;
42    /// Obtain the table from the source
43    ///
44    /// (used by Diesel to implement some traits)
45    fn target(&self) -> &Self::Target;
46}