Albirew/nyaa-pantsu
Archivé
1
0
Bifurcation 0

Workaround for SQLite search

At least we can test it in development now.
Cette révision appartient à :
bakape 2017-05-09 15:31:47 +03:00
Parent 28b07dd4bc
révision 839bc46163

Voir le fichier

@ -7,6 +7,7 @@ import (
"unicode" "unicode"
"unicode/utf8" "unicode/utf8"
"github.com/ewhal/nyaa/db"
"github.com/ewhal/nyaa/model" "github.com/ewhal/nyaa/model"
"github.com/ewhal/nyaa/service/torrent" "github.com/ewhal/nyaa/service/torrent"
"github.com/ewhal/nyaa/util/log" "github.com/ewhal/nyaa/util/log"
@ -161,8 +162,19 @@ func SearchByQuery(r *http.Request, pagenum int) (search SearchParam, tor []mode
// punctuation characters. // punctuation characters.
continue continue
} }
// TEMP: Workaround to at least make SQLite search testable for
// development.
// TODO: Actual case-insensitive search for SQLite
var operator string
if db.ORM.Dialect().GetName() == "sqlite3" {
operator = "LIKE ?"
} else {
operator = "ILIKE ?"
}
// TODO: make this faster ? // TODO: make this faster ?
conditions = append(conditions, "torrent_name ILIKE ?") conditions = append(conditions, "torrent_name "+operator)
parameters.Params = append(parameters.Params, "%"+searchQuerySplit[i]+"%") parameters.Params = append(parameters.Params, "%"+searchQuerySplit[i]+"%")
} }