mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: merge ivanvanderbyl:add-json-type-to-entql (#1112)
* Generate JSON types for entql * Correctly normalize name of json type in generated code * Override interface types for entql wheres * Actually call correct method * Implement better interface name stringer * Define JsonP in template * Cleanup and fix tests * Remove extra json predicates * Remove JSON predicates and use BytesP * Regenerate * Update entc/gen/template/dialect/sql/entql.tmpl Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * Update entql/internal/gen.go Co-authored-by: Ariel Mashraki <7413593+a8m@users.noreply.github.com> * Fix comment * all: regenerate assets Co-authored-by: Ivan Vanderbyl <ivanvanderbyl@gmail.com> Co-authored-by: Ivan Vanderbyl <ivanvanderbyl@users.noreply.github.com>
This commit is contained in:
@@ -118,7 +118,10 @@ type predicateAdder interface {
|
||||
{{ range $f := $n.Fields }}
|
||||
{{ $type := $f.Type.Type.String }}
|
||||
{{ $iface := print (pascal $type) "P" }}
|
||||
{{ if $f.IsTime }}{{ $iface = "TimeP" }}{{ else if $f.IsBytes }}{{ $iface = "BytesP" }}{{ else if $f.IsUUID }}{{ $iface = "ValueP" }}{{ end }}
|
||||
{{- if $f.IsTime }}{{ $iface = "TimeP" }}
|
||||
{{- else if or $f.IsBytes $f.IsJSON }}{{ $iface = "BytesP" }}
|
||||
{{- else if $f.IsUUID }}{{ $iface = "ValueP" }}
|
||||
{{- end }}
|
||||
// Where{{ $f.StructField }} applies the entql {{ $type }} predicate on the {{ $f.Name }} field.
|
||||
func (f *{{ $filter }}) Where{{ $f.StructField }}(p entql.{{ $iface }}) {
|
||||
f.Where(p.Field({{ $n.Package }}.{{ $f.Constant }}))
|
||||
|
||||
Reference in New Issue
Block a user