Workaround for SQLite search
At least we can test it in development now.
Cette révision appartient à :
Parent
28b07dd4bc
révision
839bc46163
1 fichiers modifiés avec 13 ajouts et 1 suppressions
|
@ -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]+"%")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Référencer dans un nouveau ticket