mirror of
https://github.com/ent/ent.git
synced 2026-04-28 05:30:56 +03:00
entc/gen: fix entql generation for ID types of Bytes, etc. (#2157)
* Fix entql generation for ID types of Bytes, etc. I was running into an issue trying to use a Bytes fieldas the ID field in a Schema, and it appears there is an currently an issue with using a Bytes field as the ID field in the entql codegen (it was outputing a function . I belive this should fix it (I tested this by adding the entql flag to the custom id integration test). I wasn't sure if the other cases I added (e.g. an ID field that is json type / time type / etc.) are actually sane ID field types, but if those don't make any sense I can remove some of those from the added conditionals. * remove redundant line
This commit is contained in:
@@ -111,7 +111,10 @@ type predicateAdder interface {
|
||||
|
||||
{{ $type := $n.ID.Type.Type.String }}
|
||||
{{ $iface := print (pascal $type) "P" }}
|
||||
{{ if $n.ID.IsUUID }}{{ $iface = "ValueP" }}{{ end }}
|
||||
{{- if $n.ID.IsTime }}{{ $iface = "TimeP" }}
|
||||
{{- else if or $n.ID.IsBytes $n.ID.IsJSON }}{{ $iface = "BytesP" }}
|
||||
{{- else if $n.ID.IsUUID }}{{ $iface = "ValueP" }}
|
||||
{{- end }}
|
||||
// WhereID applies the entql {{ $type }} predicate on the id field.
|
||||
func (f *{{ $filter }}) WhereID(p entql.{{ $iface }}) {
|
||||
f.Where(p.Field({{ $n.Package }}.{{ $n.ID.Constant }}))
|
||||
|
||||
1101
entc/integration/customid/ent/entql.go
Normal file
1101
entc/integration/customid/ent/entql.go
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4,4 +4,4 @@
|
||||
|
||||
package ent
|
||||
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema
|
||||
//go:generate go run -mod=mod entgo.io/ent/cmd/ent generate --feature sql/upsert --feature entql --header "// Copyright 2019-present Facebook Inc. All rights reserved.\n// This source code is licensed under the Apache 2.0 license found\n// in the LICENSE file in the root directory of this source tree.\n\n// Code generated by entc, DO NOT EDIT." ./schema
|
||||
|
||||
Reference in New Issue
Block a user