BREAKING CHANGE: V2 of thr SDK #12

Merged
fenpaws merged 124 commits from develop/postgresql into main 2024-07-01 20:46:28 +00:00
3 changed files with 33 additions and 3 deletions
Showing only changes of commit 768203ebd7 - Show all commits

View File

@ -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)
fenpaws marked this conversation as resolved Outdated

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.

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.
if result.Error != nil {
if errors.Is(result.Error, gorm.ErrRecordNotFound) {

View File

@ -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,
},
{

View File

@ -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,
},
{