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:
Alex Snast
2019-08-27 10:47:29 -07:00
committed by Facebook Github Bot
parent a79c1c20c0
commit 373769dfaf
159 changed files with 232 additions and 642 deletions

View File

@@ -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) }