Enum Source
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§
§impl Source
impl Source
pub fn table_with_joins(
tables: Vec<TableRef>,
from_item: TableWithJoins,
) -> Source
pub fn table_with_joins( tables: Vec<TableRef>, from_item: TableWithJoins, ) -> Source
Creates a table source from explicit table refs and a table-with-joins specification.
pub 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.
pub fn as_model_unwrap(&self) -> &SourceModel
pub fn as_model_unwrap(&self) -> &SourceModel
pub 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.
pub fn table(table: impl Into<TableRef>) -> Source
pub fn table(table: impl Into<TableRef>) -> Source
Creates a Table source from a single table reference with no joins.
pub 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.
pub fn as_table_unwrap(&self) -> &SourceTable
pub fn as_table_unwrap(&self) -> &SourceTable
Trait Implementations§
§impl From<SourceTable> for Source
impl From<SourceTable> for Source
§fn from(value: SourceTable) -> Source
fn from(value: SourceTable) -> Source
Converts to this type from the input type.
§impl<'a, T> IntoExprTarget<'a, T> for &'a Sourcewhere
T: Resolve,
impl<'a, T> IntoExprTarget<'a, T> for &'a Sourcewhere
T: Resolve,
§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