mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 12:24:38 +03:00
Fix scene marker sort by scene updated SQL error (#1777)
This commit is contained in:
@@ -3,6 +3,7 @@ package sqlite
|
||||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"github.com/stashapp/stash/pkg/database"
|
||||
"github.com/stashapp/stash/pkg/models"
|
||||
)
|
||||
@@ -159,7 +160,7 @@ func (qb *sceneMarkerQueryBuilder) Query(sceneMarkerFilter *models.SceneMarkerFi
|
||||
|
||||
query.addFilter(filter)
|
||||
|
||||
query.sortAndPagination = qb.getSceneMarkerSort(findFilter) + getPagination(findFilter)
|
||||
query.sortAndPagination = qb.getSceneMarkerSort(&query, findFilter) + getPagination(findFilter)
|
||||
idsResult, countResult, err := query.executeFind()
|
||||
if err != nil {
|
||||
return nil, 0, err
|
||||
@@ -246,13 +247,15 @@ func sceneMarkerPerformersCriterionHandler(qb *sceneMarkerQueryBuilder, performe
|
||||
}
|
||||
}
|
||||
|
||||
func (qb *sceneMarkerQueryBuilder) getSceneMarkerSort(findFilter *models.FindFilterType) string {
|
||||
func (qb *sceneMarkerQueryBuilder) getSceneMarkerSort(query *queryBuilder, findFilter *models.FindFilterType) string {
|
||||
sort := findFilter.GetSort("title")
|
||||
direction := findFilter.GetDirection()
|
||||
tableName := "scene_markers"
|
||||
if sort == "scenes_updated_at" {
|
||||
// ensure scene table is joined
|
||||
query.join(sceneTable, "", "scenes.id = scene_markers.scene_id")
|
||||
sort = "updated_at"
|
||||
tableName = "scene"
|
||||
tableName = "scenes"
|
||||
}
|
||||
return getSort(sort, direction, tableName)
|
||||
}
|
||||
|
||||
@@ -68,6 +68,21 @@ func TestMarkerCountByTagID(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func TestMarkerQuerySortBySceneUpdated(t *testing.T) {
|
||||
withTxn(func(r models.Repository) error {
|
||||
sort := "scenes_updated_at"
|
||||
_, _, err := r.SceneMarker().Query(nil, &models.FindFilterType{
|
||||
Sort: &sort,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Errorf("Error querying scene markers: %s", err.Error())
|
||||
}
|
||||
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// TODO Update
|
||||
// TODO Destroy
|
||||
// TODO Find
|
||||
|
||||
Reference in New Issue
Block a user