Skip to content

Commit

Permalink
Do not ignore order on distinct query (go-gorm#1570)
Browse files Browse the repository at this point in the history
  • Loading branch information
domenipavec authored and jinzhu committed Sep 4, 2017
1 parent 6e45625 commit c0ac6a7
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions search.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package gorm

import (
"fmt"
"regexp"
)

type search struct {
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit c0ac6a7

Please sign in to comment.