Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Modifiers triggers too late #4417

@yoshino-s

Description

@yoshino-s

In template, the modifiers template apply earlier than some other options, which makes the modifiers cannot change some options like order or limit and so on.

{{- /* Allow mutating the sql.Selector by ent extensions or user templates.*/}}
{{- with $tmpls := matchTemplate "dialect/sql/query/selector/*" }}
{{- range $tmpl := $tmpls }}
{{- xtemplate $tmpl $ }}
{{- end }}
{{- end }}
for _, p := range {{ $receiver }}.predicates {
p(selector)
}
for _, p := range {{ $receiver }}.order {
p(selector)
}
if offset := {{ $receiver }}.ctx.Offset; offset != nil {
// limit is mandatory for offset clause. We start
// with default value, and override it below if needed.
selector.Offset(*offset).Limit(math.MaxInt32)
}
if limit := {{ $receiver }}.ctx.Limit; limit != nil {
selector.Limit(*limit)
}

Should we apply the mutating templates whe all other options are applyed?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions