{{/* The line below tells Intellij/GoLand to enable the autocompletion based *gen.Type type. */}}
{{/* gotype: entgo.io/ent/entc/gen.Type */}}

{{/* A template for adding the Modify method to the query builder. */}}
{{ define "dialect/sql/query/additional/modify" }}
    {{ $builder := pascal $.Scope.Builder }}
    {{ $receiver := receiver $builder }}
    func ({{ $receiver }} *{{ $builder }}) Modify(modifier func(s *sql.Selector)) *{{ $builder }} {
        {{ $receiver }}.modifiers = append({{ $receiver }}.modifiers, modifier)
        return {{ $receiver }}
    }
{{ end }}

{{ define "dialect/sql/query/fields/additional/modify" -}}
    modifiers []func(s *sql.Selector)
{{- end -}}

{{ define "dialect/sql/query/selector/modify" }}
    {{- $receiver := pascal $.Scope.Builder | receiver }}
    for _, m := range {{ $receiver }}.modifiers {
        m(selector)
    }
{{- end -}}
