Skip to content

Commit 25bbf7d

Browse files
committed
RHINENG-21424: unify Where() call
1 parent 8a99053 commit 25bbf7d

1 file changed

Lines changed: 5 additions & 8 deletions

File tree

manager/controllers/utils.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -434,25 +434,22 @@ func buildInventoryQuery(tx *gorm.DB, key string, values []string) *gorm.DB {
434434
}
435435

436436
var cmp string
437-
val := values[0]
437+
val := []any{}
438438

439439
switch {
440-
case val == "not_nil":
440+
case values[0] == "not_nil":
441441
cmp = " is not null"
442442
case strings.Contains(key, "[sap_sids"):
443443
cmp = "::jsonb @> ?::jsonb"
444444
bval, _ := sonic.Marshal(values)
445-
val = string(bval)
445+
val = []any{string(bval)}
446446
default:
447447
cmp = " = ?"
448+
val = []any{values[0]}
448449
}
449450

450451
subq := fmt.Sprintf("%s%s", nestedFilters[key], cmp)
451-
if val == "not_nil" {
452-
return tx.Where(subq)
453-
}
454-
455-
return tx.Where(subq, val)
452+
return tx.Where(subq, val...)
456453
}
457454

458455
func Csv(ctx *gin.Context, code int, res interface{}) {

0 commit comments

Comments
 (0)