Skip to main content

char_length

Function char_length 

Source
pub fn char_length<'a, V, E>(
    expr: E,
) -> SQLExpr<'a, V, <E::SQLType as LengthPolicy<V::DialectMarker>>::Output, E::Nullable, E::Aggregate, E::Sources>
where V: SQLParam + 'a, E: Expr<'a, V>, E::SQLType: LengthPolicy<V::DialectMarker>,
Expand description

Number of characters in a text value.

Renders CHAR_LENGTH(expr) on PostgreSQL and MySQL and LENGTH(expr) on SQLite, which counts characters. The argument must be text. The result is an integer (see LengthPolicy) and keeps the argument’s nullability.

§Examples

// SQLite
assert_eq!(char_length(users.name).sql(), r#"LENGTH ("users"."name")"#);