Do not ignore order on distinct query (#1570)

This commit is contained in:
Domen Ipavec 2017-09-04 16:35:37 +02:00 committed by Jinzhu
parent 6e456250f7
commit c0ac6a7d50
1 changed files with 0 additions and 7 deletions

View File

@ -2,7 +2,6 @@ package gorm
import (
"fmt"
"regexp"
)
type search struct {
@ -73,13 +72,7 @@ func (s *search) Order(value interface{}, reorder ...bool) *search {
return s
}
var distinctSQLRegexp = regexp.MustCompile(`(?i)distinct[^a-z]+[a-z]+`)
func (s *search) Select(query interface{}, args ...interface{}) *search {
if distinctSQLRegexp.MatchString(fmt.Sprint(query)) {
s.ignoreOrderQuery = true
}
s.selects = map[string]interface{}{"query": query, "args": args}
return s
}