mirror of
https://github.com/ent/ent.git
synced 2026-05-22 09:31:45 +03:00
dialect/sql: escape EqualFold on Postgres (#2860)
* adds tests for equalFold predicates * ensure EqualFold escapes the argument on Postgres * adds tests on builder as well
This commit is contained in:
@@ -1703,14 +1703,17 @@ func (p *Predicate) EqualFold(col, sub string) *Predicate {
|
||||
// We assume the CHARACTER SET is configured to utf8mb4,
|
||||
// because this how it is defined in dialect/sql/schema.
|
||||
b.Ident(col).WriteString(" COLLATE utf8mb4_general_ci = ")
|
||||
b.Arg(strings.ToLower(sub))
|
||||
case dialect.Postgres:
|
||||
b.Ident(col).WriteString(" ILIKE ")
|
||||
w, _ := escape(sub)
|
||||
b.Arg(strings.ToLower(w))
|
||||
default: // SQLite.
|
||||
f.Lower(col)
|
||||
b.WriteString(f.String())
|
||||
b.WriteOp(OpEQ)
|
||||
b.Arg(strings.ToLower(sub))
|
||||
}
|
||||
b.Arg(strings.ToLower(sub))
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user