pub enum Source {
Model(SourceModel),
Table(SourceTable),
}Expand description
The data source for a Select statement’s FROM clause.
At the model level, the source references a model (optionally navigated via an association). After lowering, the source becomes a table with joins.
§Examples
ⓘ
use toasty_core::stmt::Source;
use toasty_core::schema::app::ModelId;
let source = Source::from(ModelId(0));
assert!(source.is_model());
assert!(!source.is_table());Variants§
Model(SourceModel)
Source is a model (app-level).
Table(SourceTable)
Source is a database table (lowered/DB-level).
Implementations§
Source§impl Source
impl Source
Sourcepub fn table_with_joins(
tables: Vec<TableRef>,
from_item: TableWithJoins,
) -> Self
pub fn table_with_joins( tables: Vec<TableRef>, from_item: TableWithJoins, ) -> Self
Creates a table source from explicit table refs and a table-with-joins specification.
Sourcepub fn as_model(&self) -> Option<&SourceModel>
pub fn as_model(&self) -> Option<&SourceModel>
Returns a reference to the inner SourceModel if this is a Model
variant.
Sourcepub fn as_model_unwrap(&self) -> &SourceModel
pub fn as_model_unwrap(&self) -> &SourceModel
Sourcepub fn model_id_unwrap(&self) -> ModelId
pub fn model_id_unwrap(&self) -> ModelId
Returns the model ID, panicking if this is not a Model source.
Sourcepub fn table(table: impl Into<TableRef>) -> Self
pub fn table(table: impl Into<TableRef>) -> Self
Creates a Table source from a single table reference with no joins.
Sourcepub fn as_table(&self) -> Option<&SourceTable>
pub fn as_table(&self) -> Option<&SourceTable>
Returns a reference to the inner SourceTable if this is a Table
variant.
Sourcepub fn as_table_unwrap(&self) -> &SourceTable
pub fn as_table_unwrap(&self) -> &SourceTable
Trait Implementations§
Source§impl From<SourceTable> for Source
impl From<SourceTable> for Source
Source§fn from(value: SourceTable) -> Self
fn from(value: SourceTable) -> Self
Converts to this type from the input type.
Source§impl<'a, T: Resolve> IntoExprTarget<'a, T> for &'a Source
impl<'a, T: Resolve> IntoExprTarget<'a, T> for &'a Source
Source§fn into_expr_target(self, schema: &'a T) -> ExprTarget<'a>
fn into_expr_target(self, schema: &'a T) -> ExprTarget<'a>
Converts
self into an ExprTarget using the provided schema.impl StructuralPartialEq for Source
Auto Trait Implementations§
impl Freeze for Source
impl RefUnwindSafe for Source
impl Send for Source
impl Sync for Source
impl Unpin for Source
impl UnwindSafe for Source
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more