Use arg for regex queries (#311)

This commit is contained in:
WithoutPants 2020-01-07 05:02:25 +11:00 committed by Leopere
parent bab7c8f250
commit 488cd5575d
2 changed files with 6 additions and 3 deletions

View file

@ -21,7 +21,7 @@ import (
"github.com/jmoiron/sqlx"
)
const testName = "Foo Bar"
const testName = "Foo's Bar"
const testExtension = ".mp4"
var testSeparators = []string{

View file

@ -293,7 +293,9 @@ func getMultiCriterionClause(table string, joinTable string, joinTableField stri
func (qb *SceneQueryBuilder) QueryAllByPathRegex(regex string) ([]*Scene, error) {
var args []interface{}
body := selectDistinctIDs("scenes") + " WHERE scenes.path regexp '(?i)" + regex + "'"
body := selectDistinctIDs("scenes") + " WHERE scenes.path regexp ?"
args = append(args, "(?i)"+regex)
idsResult, err := runIdsQuery(body, args)
@ -326,7 +328,8 @@ func (qb *SceneQueryBuilder) QueryByPathRegex(findFilter *FindFilterType) ([]*Sc
body := selectDistinctIDs("scenes")
if q := findFilter.Q; q != nil && *q != "" {
whereClauses = append(whereClauses, "scenes.path regexp '(?i)"+*q+"'")
whereClauses = append(whereClauses, "scenes.path regexp ?")
args = append(args, "(?i)"+*q)
}
sortAndPagination := qb.getSceneSort(findFilter) + getPagination(findFilter)