Skip to main content

split_part

Function split_part 

Source
pub fn split_part<'a, V, E, D, N>(
    expr: E,
    delimiter: D,
    n: N,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, <<E::Nullable as Nullability>::Or<D::Nullable> as Nullability>::Or<N::Nullable>, <<E::Aggregate as AggregateKind>::Or<D::Aggregate> as AggregateKind>::Or<N::Aggregate>, (E::Sources, (D::Sources, N::Sources))>
Expand description

The n-th field of a text value split on delimiter (SPLIT_PART), on PostgreSQL.

Fields are numbered from 1. expr and delimiter must be text and n an integer. The result is text, nullable if any argument is.

ยงExamples

// The domain part of an email address.
let domain = split_part(users.email, "@", 2);
assert_eq!(domain.sql(), r#"SPLIT_PART ("users"."email", $1, $2)"#);