mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
ent/dialect/sql: add upper and lower methods
Summary: Pull Request resolved: https://github.com/facebookincubator/ent/pull/18 Reviewed By: elys1um Differential Revision: D16916563 fbshipit-source-id: f758536103356cb5b2bacf707c7c7da931bb4560
This commit is contained in:
committed by
Facebook Github Bot
parent
85d2d6adcd
commit
e2524ff0ad
@@ -1028,6 +1028,32 @@ func (p *Predicate) Contains(col, sub string) *Predicate {
|
||||
return p.Like(col, "%"+sub+"%")
|
||||
}
|
||||
|
||||
// Lower wraps the given column with the LOWER function.
|
||||
//
|
||||
// P().EQ(sql.Lower("name"), "a8m")
|
||||
//
|
||||
func Lower(name string) string {
|
||||
var b Builder
|
||||
b.WriteString("LOWER")
|
||||
b.Nested(func(b *Builder) {
|
||||
b.Append(name)
|
||||
})
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Upper wraps the given column with the UPPER function.
|
||||
//
|
||||
// P().EQ(sql.Upper("name"), "a8m")
|
||||
//
|
||||
func Upper(name string) string {
|
||||
var b Builder
|
||||
b.WriteString("UPPER")
|
||||
b.Nested(func(b *Builder) {
|
||||
b.Append(name)
|
||||
})
|
||||
return b.String()
|
||||
}
|
||||
|
||||
// Query returns query representation of a predicate.
|
||||
func (p *Predicate) Query() (string, []interface{}) {
|
||||
return p.b.String(), p.b.args
|
||||
|
||||
Reference in New Issue
Block a user