Skip to main content

length

Function length 

Source
pub fn 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

Length of a text value (LENGTH).

SQLite and PostgreSQL count characters; MySQL counts bytes. Use char_length to count characters on every dialect. The argument must be text. The result is an integer (see LengthPolicy) and keeps the argument’s nullability.

§Examples

assert_eq!(length(users.name).sql(), r#"LENGTH ("users"."name")"#);