-
-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Make searching issues by keyword case insensitive on DB #14848
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make searching issues by keyword case insensitive on DB #14848
Conversation
Most DBs apart from SQLite will use a default Collation that is not case insensitive. This means that SearchIssuesByKeyword becomes case sensitive for db indexing - in contrast to the bleve and elastic indexers. This PR simply uses UPPER(...) to do the LIKE - and although it may be more efficient to change collations this would be a non-trivial task. Fix go-gitea#13663 Signed-off-by: Andrew Thornton <[email protected]>
I've put in 1.14 but this could move if necessary. |
This may be breaking - as it does change things but I think the previous behaviour is unintended |
Another method is to implement a custom builder.Cond, we can name it // ILike defines ilike condition
type ILike [2]string
var _ builder.Cond = ILike{"", ""}
// WriteTo write SQL to Writer
func (like ILike) WriteTo(w Writer) error {
if _, err := fmt.Fprintf(w, "%s iLIKE ?", like[0]); err != nil {
return err
}
// FIXME: if use other regular express, this will be failed. but for compatible, keep this
if like[1][0] == '%' \|\| like[1][len(like[1])-1] == '%' {
w.Append(like[1])
} else {
w.Append("%" + like[1] + "%")
}
return nil
} |
@lunny sounds like a feature request/pull to xorm and follow up pull ... |
ILIKE isn't present in sqlite, mysql or transact SQL. Changing the collation for these columns is most likely to be the correct solution but a very fiddly one indeed. |
@6543 The feature could added to xorm, but as an external var likeFunc func(s, v string) builder.Cond
// if it's postgres {
likeFunc = func(s, v string) builder.Cond {
return ILike{s,v}
}
} else {
likeFunc = func(s, v string) builder.Cond {
return builder.Like{s,v}
}
} Then replace all |
Most DBs apart from SQLite will use a default Collation that is not case insensitive.
This means that SearchIssuesByKeyword becomes case sensitive for db indexing - in
contrast to the bleve and elastic indexers.
This PR simply uses UPPER(...) to do the LIKE - and although it may be more efficient
to change collations this would be a non-trivial task.
Fix #13663
Signed-off-by: Andrew Thornton [email protected]