mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
Use instr for substring test in SQL query
There is no longer a need for the EscapeGlob function.
This commit is contained in:
parent
37186a41d4
commit
e8299a6e7c
11
store/sql.go
11
store/sql.go
|
@ -1,11 +0,0 @@
|
|||
package store
|
||||
|
||||
import "strings"
|
||||
|
||||
var globEscaper = strings.NewReplacer("\\", "\\\\", "?", "\\?", "*", "\\*")
|
||||
|
||||
// EscapeGlob escapes s to be suitable as an argument to SQLite's GLOB
|
||||
// operator.
|
||||
func EscapeGlob(s string) string {
|
||||
return globEscaper.Replace(s)
|
||||
}
|
|
@ -51,8 +51,7 @@ func convertVisitedDirs(rows *sql.Rows) ([]VisitedDir, error) {
|
|||
|
||||
func (s *Store) FindVisitedDirs(p string) ([]VisitedDir, error) {
|
||||
rows, err := s.db.Query(
|
||||
"select path, score from visited_dir where path glob ? order by score desc",
|
||||
"*"+EscapeGlob(p)+"*")
|
||||
"select path, score from visited_dir where instr(path, ?) > 0 order by score desc", p)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user