mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
entc/gen: add EqualFold and ContainsFold to string IDs (#3382)
This commit is contained in:
@@ -1723,7 +1723,7 @@ func (f Field) enums(lf *load.Field) ([]Enum, error) {
|
|||||||
// Ops returns all predicate operations of the field.
|
// Ops returns all predicate operations of the field.
|
||||||
func (f *Field) Ops() []Op {
|
func (f *Field) Ops() []Op {
|
||||||
ops := fieldOps(f)
|
ops := fieldOps(f)
|
||||||
if f.Name != "id" && f.cfg != nil && f.cfg.Storage.Ops != nil {
|
if (f.Name != "id" || !f.HasGoType()) && f.cfg != nil && f.cfg.Storage.Ops != nil {
|
||||||
ops = append(ops, f.cfg.Storage.Ops(f)...)
|
ops = append(ops, f.cfg.Storage.Ops(f)...)
|
||||||
}
|
}
|
||||||
return ops
|
return ops
|
||||||
|
|||||||
@@ -57,6 +57,16 @@ func IDLTE(id string) predicate.Pet {
|
|||||||
return predicate.Pet(sql.FieldLTE(FieldID, id))
|
return predicate.Pet(sql.FieldLTE(FieldID, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IDEqualFold applies the EqualFold predicate on the ID field.
|
||||||
|
func IDEqualFold(id string) predicate.Pet {
|
||||||
|
return predicate.Pet(sql.FieldEqualFold(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDContainsFold applies the ContainsFold predicate on the ID field.
|
||||||
|
func IDContainsFold(id string) predicate.Pet {
|
||||||
|
return predicate.Pet(sql.FieldContainsFold(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
// HasOwner applies the HasEdge predicate on the "owner" edge.
|
// HasOwner applies the HasEdge predicate on the "owner" edge.
|
||||||
func HasOwner() predicate.Pet {
|
func HasOwner() predicate.Pet {
|
||||||
return predicate.Pet(func(s *sql.Selector) {
|
return predicate.Pet(func(s *sql.Selector) {
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ func IDLTE(id string) predicate.Revision {
|
|||||||
return predicate.Revision(sql.FieldLTE(FieldID, id))
|
return predicate.Revision(sql.FieldLTE(FieldID, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IDEqualFold applies the EqualFold predicate on the ID field.
|
||||||
|
func IDEqualFold(id string) predicate.Revision {
|
||||||
|
return predicate.Revision(sql.FieldEqualFold(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDContainsFold applies the ContainsFold predicate on the ID field.
|
||||||
|
func IDContainsFold(id string) predicate.Revision {
|
||||||
|
return predicate.Revision(sql.FieldContainsFold(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
// And groups predicates with the AND operator between them.
|
// And groups predicates with the AND operator between them.
|
||||||
func And(predicates ...predicate.Revision) predicate.Revision {
|
func And(predicates ...predicate.Revision) predicate.Revision {
|
||||||
return predicate.Revision(func(s *sql.Selector) {
|
return predicate.Revision(func(s *sql.Selector) {
|
||||||
|
|||||||
@@ -56,6 +56,16 @@ func IDLTE(id string) predicate.Item {
|
|||||||
return predicate.Item(sql.FieldLTE(FieldID, id))
|
return predicate.Item(sql.FieldLTE(FieldID, id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IDEqualFold applies the EqualFold predicate on the ID field.
|
||||||
|
func IDEqualFold(id string) predicate.Item {
|
||||||
|
return predicate.Item(sql.FieldEqualFold(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
|
// IDContainsFold applies the ContainsFold predicate on the ID field.
|
||||||
|
func IDContainsFold(id string) predicate.Item {
|
||||||
|
return predicate.Item(sql.FieldContainsFold(FieldID, id))
|
||||||
|
}
|
||||||
|
|
||||||
// Text applies equality check predicate on the "text" field. It's identical to TextEQ.
|
// Text applies equality check predicate on the "text" field. It's identical to TextEQ.
|
||||||
func Text(v string) predicate.Item {
|
func Text(v string) predicate.Item {
|
||||||
return predicate.Item(sql.FieldEQ(FieldText, v))
|
return predicate.Item(sql.FieldEQ(FieldText, v))
|
||||||
|
|||||||
Reference in New Issue
Block a user