mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Use arg for regex queries (#311)
This commit is contained in:
@@ -21,7 +21,7 @@ import (
|
|||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
)
|
)
|
||||||
|
|
||||||
const testName = "Foo Bar"
|
const testName = "Foo's Bar"
|
||||||
const testExtension = ".mp4"
|
const testExtension = ".mp4"
|
||||||
|
|
||||||
var testSeparators = []string{
|
var testSeparators = []string{
|
||||||
|
|||||||
@@ -293,7 +293,9 @@ func getMultiCriterionClause(table string, joinTable string, joinTableField stri
|
|||||||
|
|
||||||
func (qb *SceneQueryBuilder) QueryAllByPathRegex(regex string) ([]*Scene, error) {
|
func (qb *SceneQueryBuilder) QueryAllByPathRegex(regex string) ([]*Scene, error) {
|
||||||
var args []interface{}
|
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)
|
idsResult, err := runIdsQuery(body, args)
|
||||||
|
|
||||||
@@ -326,7 +328,8 @@ func (qb *SceneQueryBuilder) QueryByPathRegex(findFilter *FindFilterType) ([]*Sc
|
|||||||
body := selectDistinctIDs("scenes")
|
body := selectDistinctIDs("scenes")
|
||||||
|
|
||||||
if q := findFilter.Q; q != nil && *q != "" {
|
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)
|
sortAndPagination := qb.getSceneSort(findFilter) + getPagination(findFilter)
|
||||||
|
|||||||
Reference in New Issue
Block a user