Enum sql::plan::expr::CoercibleScalarExpr [−][src]
pub enum CoercibleScalarExpr {
Coerced(HirScalarExpr),
Parameter(usize),
LiteralNull,
LiteralString(String),
LiteralRecord(Vec<CoercibleScalarExpr>),
}
Expand description
A CoercibleScalarExpr
is a HirScalarExpr
whose type is not fully
determined. Several SQL expressions can be freely coerced based upon where
in the expression tree they appear. For example, the string literal ‘42’
will be automatically coerced to the integer 42 if used in a numeric
context:
SELECT '42' + 42
This separate type gives the code that needs to interact with coercions very fine-grained control over what coercions happen and when.
The primary driver of coercion is function and operator selection, as choosing the correct function or operator implementation depends on the type of the provided arguments. Coercion also occurs at the very root of the scalar expression tree. For example in
SELECT ... WHERE $1
the WHERE
clause will coerce the contained unconstrained type parameter
$1
to have type bool.
Variants
Coerced(HirScalarExpr)
Tuple Fields
Parameter(usize)
Tuple Fields
0: usize
LiteralNull
LiteralString(String)
Tuple Fields
0: String
LiteralRecord(Vec<CoercibleScalarExpr>)
Tuple Fields
Implementations
pub fn type_as(
self,
ecx: &ExprContext<'_>,
ty: &ScalarType
) -> Result<HirScalarExpr, PlanError>
pub fn cast_to(
self,
ecx: &ExprContext<'_>,
ccx: CastContext,
ty: &ScalarType
) -> Result<HirScalarExpr, PlanError>
Trait Implementations
type Type = Option<ColumnType>
fn typ(
&self,
outers: &[RelationType],
inner: &RelationType,
params: &BTreeMap<usize, ScalarType>
) -> Self::Type
fn typ(
&self,
outers: &[RelationType],
inner: &RelationType,
params: &BTreeMap<usize, ScalarType>
) -> Self::Type
Computes the type of the expression.
Performs the conversion.
Auto Trait Implementations
impl RefUnwindSafe for CoercibleScalarExpr
impl Send for CoercibleScalarExpr
impl Sync for CoercibleScalarExpr
impl Unpin for CoercibleScalarExpr
impl UnwindSafe for CoercibleScalarExpr
Blanket Implementations
Mutably borrows from an owned value. Read more
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more