diff --git a/internal/postgres/tag.go b/internal/postgres/tag.go index 6b963f7..7ca240c 100644 --- a/internal/postgres/tag.go +++ b/internal/postgres/tag.go @@ -69,7 +69,7 @@ func GetAllTagByTagsType(ctx context.Context, db *gorm.DB, tagType models.TagTyp return nil, &otterError.EntityValidationFailed{Reason: "tagType cannot be empty"} } - result := db.WithContext(ctx).Find(&tags).Where("tag_type = ?", tagType) + result := db.WithContext(ctx).Model(&models.Tag{}).Where("tag_type = ?", tagType).Scan(&tags) if result.Error != nil { if errors.Is(result.Error, gorm.ErrRecordNotFound) { diff --git a/internal/postgres/tag_test.go b/internal/postgres/tag_test.go index a976bd4..ab15604 100644 --- a/internal/postgres/tag_test.go +++ b/internal/postgres/tag_test.go @@ -1050,6 +1050,21 @@ func TestGetAllTagByTagType(t *testing.T) { }, } + expectetResult := []models.Tag{ + { + Name: "JayTheFerret", + Type: models.Character, + }, + { + Name: "SoXX", + Type: models.Character, + }, + { + Name: "Alphyron", + Type: models.Character, + }, + } + for _, tag := range validTags { err = CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type) if err != nil { @@ -1076,7 +1091,7 @@ func TestGetAllTagByTagType(t *testing.T) { db: gormDB, tagType: models.Character, }, - want: validTags, + want: expectetResult, wantErr: false, }, { diff --git a/pkg/database/postgres_test.go b/pkg/database/postgres_test.go index f00602e..56e2036 100644 --- a/pkg/database/postgres_test.go +++ b/pkg/database/postgres_test.go @@ -3174,6 +3174,21 @@ func Test_postgresqlConnection_GetAllTagsByTagType(t *testing.T) { }, } + expectetResult := []models.Tag{ + { + Name: "JayTheFerret", + Type: models.Character, + }, + { + Name: "SoXX", + Type: models.Character, + }, + { + Name: "Alphyron", + Type: models.Character, + }, + } + for _, tag := range validTags { err = postgres.CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type) if err != nil { @@ -3198,7 +3213,7 @@ func Test_postgresqlConnection_GetAllTagsByTagType(t *testing.T) { ctx: ctx, tagType: models.Character, }, - want: validTags, + want: expectetResult, wantErr: false, }, {