mirror of
https://github.com/ent/ent.git
synced 2026-05-24 09:31:56 +03:00
ent/gen: adding EqualFold predicate for string fields
Summary: Similar to `ContainsFold` predicate requires `--storage=sql` argument to be passed to entc. Reviewed By: a8m Differential Revision: D17074805 fbshipit-source-id: ced299154417fe2c9007cd6a7a504f53c8b2ef98
This commit is contained in:
committed by
Facebook Github Bot
parent
a79c1c20c0
commit
373769dfaf
@@ -1024,6 +1024,14 @@ func (p *Predicate) HasSuffix(col, suffix string) *Predicate {
|
||||
return p.Like(col, "%"+suffix)
|
||||
}
|
||||
|
||||
// EqualFold is a helper predicate that applies the "=" predicate with case-folding.
|
||||
func EqualFold(col, sub string) *Predicate { return (&Predicate{}).EqualFold(col, sub) }
|
||||
|
||||
// EqualFold is a helper predicate that applies the "=" predicate with case-folding.
|
||||
func (p *Predicate) EqualFold(col, sub string) *Predicate {
|
||||
return p.EQ(Lower(col), strings.ToLower(sub))
|
||||
}
|
||||
|
||||
// Contains is a helper predicate that checks substring using the LIKE predicate.
|
||||
func Contains(col, sub string) *Predicate { return (&Predicate{}).Contains(col, sub) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user