diff --git a/query_test.go b/query_test.go index 866d81d2..9531b33e 100644 --- a/query_test.go +++ b/query_test.go @@ -360,6 +360,11 @@ func TestOrderAndPluck(t *testing.T) { t.Errorf("Order with multiple orders") } + var ages6 []int64 + if err := scopedb.Order("").Pluck("age", &ages6).Error; err != nil { + t.Errorf("An empty string as order clause produces invalid queries") + } + DB.Model(User{}).Select("name, age").Find(&[]User{}) } diff --git a/search.go b/search.go index 8a4f4df6..23dac2c3 100644 --- a/search.go +++ b/search.go @@ -67,7 +67,7 @@ func (s *search) Order(value interface{}, reorder ...bool) *search { s.orders = []interface{}{} } - if value != nil { + if value != nil && value != "" { s.orders = append(s.orders, value) } return s