pub struct Select {
pub returning: Returning,
pub source: Source,
pub filter: Filter,
pub distinct: bool,
}Expand description
A SELECT expression within a query body.
Represents the combination of a data source, a filter (WHERE clause), and a projection (RETURNING/SELECT list). This is the most common query body type.
At the model level, the source is a model with optional association includes. After lowering, the source becomes a table with joins.
§Examples
use toasty_core::stmt::{Select, Source, Filter};
use toasty_core::schema::app::ModelId;
let select = Select::new(Source::from(ModelId(0)), Filter::ALL);
assert!(select.source.is_model());Fields§
§returning: ReturningThe projection (what columns/fields to return).
source: SourceThe data source (FROM clause). At the model level this is a model
reference; at the table level this is a table with joins.
filter: FilterThe filter (WHERE clause).
distinct: boolWhen true, the query removes duplicate rows (SELECT DISTINCT).
Used by multi-step (via) .include() lowering, where a JOIN
through the path can yield duplicate target rows that must collapse
to distinct targets.
Implementations§
Source§impl Select
impl Select
Sourcepub fn new(source: impl Into<Source>, filter: impl Into<Filter>) -> Self
pub fn new(source: impl Into<Source>, filter: impl Into<Filter>) -> Self
Creates a new Select with the given source and filter, defaulting to
a model-level returning clause with no includes.
Sourcepub fn add_filter(&mut self, filter: impl Into<Filter>)
pub fn add_filter(&mut self, filter: impl Into<Filter>)
Adds an additional filter, AND-ing it with any existing filter.
Trait Implementations§
Source§impl From<SourceModel> for Select
impl From<SourceModel> for Select
Source§fn from(value: SourceModel) -> Self
fn from(value: SourceModel) -> Self
Source§impl<'a, T: Resolve> IntoExprTarget<'a, T> for &'a Select
impl<'a, T: Resolve> IntoExprTarget<'a, T> for &'a Select
Source§fn into_expr_target(self, schema: &'a T) -> ExprTarget<'a>
fn into_expr_target(self, schema: &'a T) -> ExprTarget<'a>
self into an ExprTarget using the provided schema.