mirror of https://github.com/velour/catbase.git
Switch fact back to like matching from regexp
This commit is contained in:
parent
d24f48862c
commit
e77c082db6
|
@ -95,7 +95,7 @@ func (f *factoid) delete(db *sqlx.DB) error {
|
||||||
|
|
||||||
func getFacts(db *sqlx.DB, fact string, tidbit string) ([]*factoid, error) {
|
func getFacts(db *sqlx.DB, fact string, tidbit string) ([]*factoid, error) {
|
||||||
var fs []*factoid
|
var fs []*factoid
|
||||||
rows, err := db.Query(`select
|
query := `select
|
||||||
id,
|
id,
|
||||||
fact,
|
fact,
|
||||||
tidbit,
|
tidbit,
|
||||||
|
@ -105,9 +105,10 @@ func getFacts(db *sqlx.DB, fact string, tidbit string) ([]*factoid, error) {
|
||||||
accessed,
|
accessed,
|
||||||
count
|
count
|
||||||
from factoid
|
from factoid
|
||||||
where fact regexp ?
|
where fact like ?
|
||||||
and tidbit regexp ?;`,
|
and tidbit like ?;`
|
||||||
fact, tidbit)
|
rows, err := db.Query(query,
|
||||||
|
"%"+fact+"%", "%"+tidbit+"%")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error regexping for facts: %s", err)
|
log.Printf("Error regexping for facts: %s", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -672,7 +673,7 @@ func (p *Factoid) serveQuery(w http.ResponseWriter, r *http.Request) {
|
||||||
"linkify": linkify,
|
"linkify": linkify,
|
||||||
}
|
}
|
||||||
if e := r.FormValue("entry"); e != "" {
|
if e := r.FormValue("entry"); e != "" {
|
||||||
entries, err := getFacts(p.db, e, ".*")
|
entries, err := getFacts(p.db, e, "")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Println("Web error searching: ", err)
|
log.Println("Web error searching: ", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue