mirror of https://github.com/go-gorm/gorm.git
Do not ignore order on distinct query (#1570)
This commit is contained in:
parent
6e456250f7
commit
c0ac6a7d50
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue