BREAKING CHANGE: V2 of thr SDK #12
@ -69,7 +69,7 @@ func GetAllTagByTagsType(ctx context.Context, db *gorm.DB, tagType models.TagTyp
|
|||||||
return nil, &otterError.EntityValidationFailed{Reason: "tagType cannot be empty"}
|
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)
|
||||||
fenpaws marked this conversation as resolved
Outdated
|
|||||||
|
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||||
|
@ -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 {
|
for _, tag := range validTags {
|
||||||
err = CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type)
|
err = CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -1076,7 +1091,7 @@ func TestGetAllTagByTagType(t *testing.T) {
|
|||||||
db: gormDB,
|
db: gormDB,
|
||||||
tagType: models.Character,
|
tagType: models.Character,
|
||||||
},
|
},
|
||||||
want: validTags,
|
want: expectetResult,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -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 {
|
for _, tag := range validTags {
|
||||||
err = postgres.CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type)
|
err = postgres.CreateTag(ctx, gormDB, models.AnthroveTagName(tag.Name), tag.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -3198,7 +3213,7 @@ func Test_postgresqlConnection_GetAllTagsByTagType(t *testing.T) {
|
|||||||
ctx: ctx,
|
ctx: ctx,
|
||||||
tagType: models.Character,
|
tagType: models.Character,
|
||||||
},
|
},
|
||||||
want: validTags,
|
want: expectetResult,
|
||||||
wantErr: false,
|
wantErr: false,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user
please use Scan instead of Find if you have a Where clause.
Or if you use find, put the Filter into the find function. Also its best practice if you move the Find, Scan, Create, ... as last method.