mirror of
https://github.com/zitadel/zitadel.git
synced 2025-01-10 09:43:41 +00:00
simplify milestone by instance ids query
This commit is contained in:
parent
4cc9126435
commit
d3635bb96b
@ -3,8 +3,6 @@ package query
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"fmt"
|
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
sq "github.com/Masterminds/squirrel"
|
sq "github.com/Masterminds/squirrel"
|
||||||
@ -78,14 +76,7 @@ func (q *Queries) SearchMilestones(ctx context.Context, instanceIDs []string, qu
|
|||||||
if len(instanceIDs) == 0 {
|
if len(instanceIDs) == 0 {
|
||||||
instanceIDs = []string{authz.GetInstance(ctx).InstanceID()}
|
instanceIDs = []string{authz.GetInstance(ctx).InstanceID()}
|
||||||
}
|
}
|
||||||
instanceIDParams := make([]string, len(instanceIDs))
|
stmt, args, err := queries.toQuery(query).Where(sq.Eq{MilestoneInstanceIDColID.identifier(): instanceIDs}).ToSql()
|
||||||
instanceIDArgs := make([]interface{}, len(instanceIDs))
|
|
||||||
for idx := range instanceIDs {
|
|
||||||
instanceIDParams[idx] = fmt.Sprintf("$%d", idx+1)
|
|
||||||
instanceIDArgs[idx] = instanceIDs[idx]
|
|
||||||
}
|
|
||||||
expr := fmt.Sprintf("%s IN (%s)", MilestoneInstanceIDColID.name, strings.Join(instanceIDParams, ","))
|
|
||||||
stmt, args, err := queries.toQuery(query).Where(sq.Expr(expr, instanceIDArgs...)).ToSql()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.ThrowInternal(err, "QUERY-A9i5k", "Errors.Query.SQLStatement")
|
return nil, errors.ThrowInternal(err, "QUERY-A9i5k", "Errors.Query.SQLStatement")
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user