Skip to main content

substr

Function substr 

Source
pub fn substr<'a, V, E, S, L>(
    expr: E,
    start: S,
    len: L,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, <<E::Nullable as Nullability>::Or<S::Nullable> as Nullability>::Or<L::Nullable>, <<E::Aggregate as AggregateKind>::Or<S::Aggregate> as AggregateKind>::Or<L::Aggregate>, (E::Sources, (S::Sources, L::Sources))>
where V: SQLParam + 'a, E: Expr<'a, V>, E::SQLType: Textual, S: Expr<'a, V>, S::SQLType: Integral, S::Nullable: Nullability, S::Aggregate: AggregateKind, L: Expr<'a, V>, L::SQLType: Integral, L::Nullable: Nullability, L::Aggregate: AggregateKind,
Expand description

Part of a text value (SUBSTR(expr, start, len)).

Returns len characters starting at start, counting from 1. expr must be text; start and len must be integers. The result is text, nullable if any argument is.

ยงExamples

// The first three characters.
let prefix = substr(users.name, 1, 3);
assert_eq!(prefix.sql(), r#"SUBSTR ("users"."name", ?, ?)"#);