Skip to content

Commit

Permalink
pgsql more bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
NodudeWasTaken committed Oct 25, 2024
1 parent 2239acd commit 49cea00
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
9 changes: 7 additions & 2 deletions pkg/scene/update_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ func TestUpdater_IsEmpty(t *testing.T) {
}
}

func getUUID(_ string) string {
// TODO: Encode input string
return "00000000-0000-0000-0000-000000000000"
}

func TestUpdater_Update(t *testing.T) {
const (
sceneID = iota + 1
Expand All @@ -106,7 +111,7 @@ func TestUpdater_Update(t *testing.T) {

performerIDs := []int{performerID}
tagIDs := []int{tagID}
stashID := "stashID"
stashID := getUUID("stashID")
endpoint := "endpoint"

title := "title"
Expand Down Expand Up @@ -234,7 +239,7 @@ func TestUpdateSet_UpdateInput(t *testing.T) {
performerIDStrs := intslice.IntSliceToStringSlice(performerIDs)
tagIDs := []int{tagID}
tagIDStrs := intslice.IntSliceToStringSlice(tagIDs)
stashID := "stashID"
stashID := getUUID("stashID")
endpoint := "endpoint"
stashIDs := []models.StashID{
{
Expand Down
4 changes: 2 additions & 2 deletions pkg/sqlite/performer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1703,7 +1703,7 @@ func testPerformerStashIDs(ctx context.Context, t *testing.T, s *models.Performe
assert.Len(t, s.StashIDs.List(), 0)

// add stash ids
const stashIDStr = "stashID"
var stashIDStr = getUUID("stashID")
const endpoint = "endpoint"
stashID := models.StashID{
StashID: stashIDStr,
Expand Down Expand Up @@ -1969,7 +1969,7 @@ func TestPerformerStore_FindByStashID(t *testing.T) {
{
name: "non-existing",
stashID: models.StashID{
StashID: getPerformerStringValue(performerIdxWithScene, "stashid"),
StashID: getUUID(getPerformerStringValue(performerIdxWithScene, "stashid")),
Endpoint: "non-existing",
},
expectedIDs: []int{},
Expand Down
6 changes: 3 additions & 3 deletions pkg/sqlite/scene_marker_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,18 @@ func (qb *sceneMarkerFilterHandler) tagsCriterionHandler(criterion *models.Hiera
}

if len(tags.Value) > 0 {
valuesClause, err := getHierarchicalValues(ctx, tags.Value, tagTable, "tags_relations", "parent_id", "child_id", tags.Depth, true)
valuesClause, err := getHierarchicalValues(ctx, tags.Value, tagTable, "tags_relations", "parent_id", "child_id", tags.Depth, false)
if err != nil {
f.setError(err)
return
}

f.addWith(`marker_tags AS (
SELECT mt.scene_marker_id, t.column1 AS root_tag_id FROM scene_markers_tags mt
INNER JOIN ` + valuesClause + ` t ON t.column2 = mt.tag_id
INNER JOIN (` + valuesClause + `) t ON t.column2 = mt.tag_id
UNION
SELECT m.id, t.column1 FROM scene_markers m
INNER JOIN ` + valuesClause + ` t ON t.column2 = m.primary_tag_id
INNER JOIN (` + valuesClause + `) t ON t.column2 = m.primary_tag_id
)`)

f.addLeftJoin("marker_tags", "", "marker_tags.scene_marker_id = scene_markers.id")
Expand Down
2 changes: 1 addition & 1 deletion pkg/sqlite/scene_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4374,7 +4374,7 @@ func testSceneStashIDs(ctx context.Context, t *testing.T, s *models.Scene) {
assert.Len(t, s.StashIDs.List(), 0)

// add stash ids
const stashIDStr = "stashID"
var stashIDStr = getUUID("stashID")
const endpoint = "endpoint"
stashID := models.StashID{
StashID: stashIDStr,
Expand Down
2 changes: 1 addition & 1 deletion pkg/sqlite/stash_id_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ func testStashIDReaderWriter(ctx context.Context, t *testing.T, r stashIDReaderW
testNoStashIDs(ctx, t, r, -1)

// add stash ids
const stashIDStr = "stashID"
var stashIDStr = getUUID("stashID")
const endpoint = "endpoint"
stashID := models.StashID{
StashID: stashIDStr,
Expand Down
2 changes: 1 addition & 1 deletion pkg/sqlite/studio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ func testStudioStashIDs(ctx context.Context, t *testing.T, s *models.Studio) {
assert.Len(t, s.StashIDs.List(), 0)

// add stash ids
const stashIDStr = "stashID"
var stashIDStr = getUUID("stashID")
const endpoint = "endpoint"
stashID := models.StashID{
StashID: stashIDStr,
Expand Down

0 comments on commit 49cea00

Please sign in to comment.