diff --git a/scope.go b/scope.go index d82cadbc..21d98ad6 100644 --- a/scope.go +++ b/scope.go @@ -1324,7 +1324,7 @@ func (scope *Scope) autoIndex() *Scope { } func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (results [][]interface{}) { - resultMap := make(map[string][]interface{}) + resultMap := make(map[string]bool) for _, value := range values { indirectValue := indirect(reflect.ValueOf(value)) @@ -1345,7 +1345,8 @@ func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (r if hasValue { h := fmt.Sprint(result...) if _, exist := resultMap[h]; !exist { - resultMap[h] = result + resultMap[h] = true + results = append(results, result) } } } @@ -1363,14 +1364,12 @@ func (scope *Scope) getColumnAsArray(columns []string, values ...interface{}) (r if hasValue { h := fmt.Sprint(result...) if _, exist := resultMap[h]; !exist { - resultMap[h] = result + resultMap[h] = true + results = append(results, result) } } } } - for _, v := range resultMap { - results = append(results, v) - } return }