{{/* 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 additional where clauses to specific types. */}}
{{ define "where/additional/strings" }}
	{{ range $f := $.Fields }}
		{{ if $f.IsString }}
			{{ $func := print $f.StructField "Glob" }}
			// {{ $func }} applies the Glob predicate on the {{ quote $f.Name }} field.
			func {{ $func }}(pattern string) predicate.{{ $.Name }} {
				return predicate.{{ $.Name }}(func(s *sql.Selector) {
					s.Where(sql.P(func(b *sql.Builder) {
						b.Ident(s.C({{ $f.Constant }}))
						b.WriteString(" glob ")
						b.Arg(pattern)
					}))
				})
			}
		{{ end }}
	{{ end }}
{{ end }}
