Skip to main content

string_agg

Function string_agg 

Source
pub fn string_agg<'a, V, E, D>(
    expr: E,
    delimiter: D,
) -> SQLExpr<'a, V, <V::DialectMarker as DialectTypes>::Text, Null, Agg, (E::Sources, D::Sources)>
where V: SQLParam + 'a, V::DialectMarker: DialectSupports<PostgresAggregate>, E: Expr<'a, V>, E::SQLType: Textual, D: Expr<'a, V>, D::SQLType: Textual,
Expand description

Joins text values with a delimiter (STRING_AGG), on PostgreSQL.

Both arguments must be text. The result is text, nullable, and an aggregate. On SQLite and MySQL, use group_concat.

ยงExamples

let names = string_agg(users.name, ", ");
assert_eq!(names.sql(), r#"STRING_AGG ("users"."name", $1)"#);