From 89b663a262e885aa068eae3b7bc21655885d1e90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=BE=E9=A1=BA?= <15272782842@163.com> Date: Fri, 6 Sep 2024 22:29:45 +0800 Subject: [PATCH] add postgres StringAgg func --- field/expr.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/field/expr.go b/field/expr.go index 17175a49..5799f566 100644 --- a/field/expr.go +++ b/field/expr.go @@ -207,6 +207,10 @@ func (e expr) GroupConcat() Expr { return e.setE(clause.Expr{SQL: "GROUP_CONCAT(?)", Vars: []interface{}{e.RawExpr()}}) } +func (e expr) StringAgg() Expr { + return e.setE(clause.Expr{SQL: "STRING_AGG(?, ',')", Vars: []interface{}{e.RawExpr()}}) +} + // ======================== comparison between columns ======================== func (e expr) EqCol(col Expr) Expr { return e.setE(clause.Expr{SQL: "? = ?", Vars: []interface{}{e.RawExpr(), col.RawExpr()}})