From 3156191b837c046717d2a91967fd914d846877d6 Mon Sep 17 00:00:00 2001 From: WithoutPants <53250216+WithoutPants@users.noreply.github.com> Date: Mon, 24 Jun 2024 16:02:46 +1000 Subject: [PATCH] Fix scene marker query (#5014) --- pkg/sqlite/scene_marker.go | 1 + pkg/sqlite/scene_marker_test.go | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/pkg/sqlite/scene_marker.go b/pkg/sqlite/scene_marker.go index 158916a82..87a849d20 100644 --- a/pkg/sqlite/scene_marker.go +++ b/pkg/sqlite/scene_marker.go @@ -301,6 +301,7 @@ func (qb *SceneMarkerStore) makeQuery(ctx context.Context, sceneMarkerFilter *mo distinctIDs(&query, sceneMarkerTable) if q := findFilter.Q; q != nil && *q != "" { + query.join(sceneTable, "", "scenes.id = scene_markers.scene_id") query.join(tagTable, "", "scene_markers.primary_tag_id = tags.id") searchColumns := []string{"scene_markers.title", "scenes.title", "tags.name"} query.parseQueryString(searchColumns, *q) diff --git a/pkg/sqlite/scene_marker_test.go b/pkg/sqlite/scene_marker_test.go index fffd0b88f..0a8343a8b 100644 --- a/pkg/sqlite/scene_marker_test.go +++ b/pkg/sqlite/scene_marker_test.go @@ -74,6 +74,27 @@ func TestMarkerCountByTagID(t *testing.T) { }) } +func TestMarkerQueryQ(t *testing.T) { + withTxn(func(ctx context.Context) error { + q := getSceneTitle(sceneIdxWithMarkers) + m, _, err := db.SceneMarker.Query(ctx, nil, &models.FindFilterType{ + Q: &q, + }) + + if err != nil { + t.Errorf("Error querying scene markers: %s", err.Error()) + } + + if !assert.Greater(t, len(m), 0) { + return nil + } + + assert.Equal(t, sceneIDs[sceneIdxWithMarkers], m[0].SceneID) + + return nil + }) +} + func TestMarkerQuerySortBySceneUpdated(t *testing.T) { withTxn(func(ctx context.Context) error { sort := "scenes_updated_at"