From e77c082db6be9bd242be957a70a0e0ec890801d3 Mon Sep 17 00:00:00 2001 From: Chris Sexton Date: Fri, 15 Apr 2016 14:48:35 -0400 Subject: [PATCH] Switch fact back to like matching from regexp --- plugins/fact/factoid.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/plugins/fact/factoid.go b/plugins/fact/factoid.go index fc87876..bad0063 100644 --- a/plugins/fact/factoid.go +++ b/plugins/fact/factoid.go @@ -95,7 +95,7 @@ func (f *factoid) delete(db *sqlx.DB) error { func getFacts(db *sqlx.DB, fact string, tidbit string) ([]*factoid, error) { var fs []*factoid - rows, err := db.Query(`select + query := `select id, fact, tidbit, @@ -105,9 +105,10 @@ func getFacts(db *sqlx.DB, fact string, tidbit string) ([]*factoid, error) { accessed, count from factoid - where fact regexp ? - and tidbit regexp ?;`, - fact, tidbit) + where fact like ? + and tidbit like ?;` + rows, err := db.Query(query, + "%"+fact+"%", "%"+tidbit+"%") if err != nil { log.Printf("Error regexping for facts: %s", err) return nil, err @@ -672,7 +673,7 @@ func (p *Factoid) serveQuery(w http.ResponseWriter, r *http.Request) { "linkify": linkify, } if e := r.FormValue("entry"); e != "" { - entries, err := getFacts(p.db, e, ".*") + entries, err := getFacts(p.db, e, "") if err != nil { log.Println("Web error searching: ", err) }