diff --git a/pkg/repositories/gormimpl/launch_plan_repo.go b/pkg/repositories/gormimpl/launch_plan_repo.go index dc379ed03..a1462feca 100644 --- a/pkg/repositories/gormimpl/launch_plan_repo.go +++ b/pkg/repositories/gormimpl/launch_plan_repo.go @@ -166,7 +166,7 @@ func (r *LaunchPlanRepo) ListLaunchPlanIdentifiers(ctx context.Context, input in // Scan the results into a list of launch plans var launchPlans []models.LaunchPlan timer := r.metrics.ListIdentifiersDuration.Start() - tx.Select([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&launchPlans) + tx.Distinct([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&launchPlans) timer.Stop() if tx.Error != nil { return interfaces.LaunchPlanCollectionOutput{}, r.errorTransformer.ToFlyteAdminError(tx.Error) diff --git a/pkg/repositories/gormimpl/named_entity_repo.go b/pkg/repositories/gormimpl/named_entity_repo.go index 0e698601e..3e7813284 100644 --- a/pkg/repositories/gormimpl/named_entity_repo.go +++ b/pkg/repositories/gormimpl/named_entity_repo.go @@ -33,8 +33,8 @@ func getSubQueryJoin(db *gorm.DB, tableName string, input interfaces.ListNamedEn Table(tableName). Where(map[string]interface{}{Project: input.Project, Domain: input.Domain}). Limit(input.Limit). - Group(identifierGroupBy). - Offset(input.Offset) + Offset(input.Offset). + Group(identifierGroupBy) // Apply consistent sort ordering. if input.SortParameter != nil { @@ -198,7 +198,7 @@ func (r *NamedEntityRepo) List(ctx context.Context, input interfaces.ListNamedEn var entities []models.NamedEntity timer := r.metrics.ListDuration.Start() - tx.Select(getSelectForNamedEntity(innerJoinTableAlias, input.ResourceType)).Table(namedEntityMetadataTableName).Group(getGroupByForNamedEntity).Scan(&entities) + tx.Distinct(getSelectForNamedEntity(innerJoinTableAlias, input.ResourceType)).Table(namedEntityMetadataTableName).Group(getGroupByForNamedEntity).Scan(&entities) timer.Stop() diff --git a/pkg/repositories/gormimpl/task_repo.go b/pkg/repositories/gormimpl/task_repo.go index f48c6ca11..ecfbc8a28 100644 --- a/pkg/repositories/gormimpl/task_repo.go +++ b/pkg/repositories/gormimpl/task_repo.go @@ -113,7 +113,7 @@ func (r *TaskRepo) ListTaskIdentifiers(ctx context.Context, input interfaces.Lis // Scan the results into a list of tasks var tasks []models.Task timer := r.metrics.ListIdentifiersDuration.Start() - tx.Select([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&tasks) + tx.Distinct([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&tasks) timer.Stop() if tx.Error != nil { return interfaces.TaskCollectionOutput{}, r.errorTransformer.ToFlyteAdminError(tx.Error) diff --git a/pkg/repositories/gormimpl/workflow_repo.go b/pkg/repositories/gormimpl/workflow_repo.go index 2c78cb2c4..69405b367 100644 --- a/pkg/repositories/gormimpl/workflow_repo.go +++ b/pkg/repositories/gormimpl/workflow_repo.go @@ -110,7 +110,7 @@ func (r *WorkflowRepo) ListIdentifiers(ctx context.Context, input interfaces.Lis // Scan the results into a list of workflows var workflows []models.Workflow timer := r.metrics.ListIdentifiersDuration.Start() - tx.Select([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&workflows) + tx.Distinct([]string{Project, Domain, Name}).Group(identifierGroupBy).Scan(&workflows) timer.Stop() if tx.Error != nil { return interfaces.WorkflowCollectionOutput{}, r.errorTransformer.ToFlyteAdminError(tx.Error)