mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
Summary: Pull Request resolved: https://github.com/facebookexternal/fbc/pull/1229 Reviewed By: alexsn Differential Revision: D16539934 fbshipit-source-id: b3a8bf1f1be6f65ad3f649cd921ea20fc24182bf
28 lines
753 B
Cheetah
28 lines
753 B
Cheetah
{{ define "dialect/sql/order" -}}
|
|
{{- $f := $.Scope.Func -}}
|
|
func(s *sql.Selector) {
|
|
for _, f := range fields {
|
|
s.OrderBy(sql.{{ $f }}(f))
|
|
}
|
|
}
|
|
{{- end }}
|
|
|
|
{{/* custom signature for group-by function */}}
|
|
{{ define "dialect/sql/group/signature" -}}
|
|
// SQL the column wrapped with the aggregation function.
|
|
SQL func(*sql.Selector) string
|
|
{{- end }}
|
|
|
|
{{ define "dialect/sql/group/as" -}}
|
|
func(s *sql.Selector) string {
|
|
return sql.As(fn.SQL(s), end)
|
|
}
|
|
{{- end }}
|
|
|
|
{{ define "dialect/sql/group/func" -}}
|
|
{{- $fn := $.Scope.Func }}
|
|
{{- $withField := $.Scope.WithField }}
|
|
func(s *sql.Selector) string {
|
|
return sql.{{ if eq $fn "Mean" }}Avg{{ else }}{{ $fn }}{{ end }}({{ if $withField }}s.C(field){{ else }}"*"{{ end }})
|
|
}
|
|
{{- end }} |