ignore the processing of the results.

This commit is contained in:
tick 2019-04-16 23:17:03 +08:00
parent 7bc3561503
commit fee84975b6
2 changed files with 24 additions and 21 deletions

View File

@ -777,7 +777,7 @@ func (scope *Scope) selectSQL() string {
} }
func (scope *Scope) orderSQL() string { func (scope *Scope) orderSQL() string {
if len(scope.Search.orders) == 0 || scope.Search.ignoreOrderQuery { if len(scope.Search.orders) == 0 || scope.Search.ignoreProcessingResult {
return "" return ""
} }
@ -797,6 +797,9 @@ func (scope *Scope) orderSQL() string {
} }
func (scope *Scope) limitAndOffsetSQL() string { func (scope *Scope) limitAndOffsetSQL() string {
if scope.Search.ignoreProcessingResult {
return ""
}
return scope.Dialect().LimitAndOffsetSQL(scope.Search.limit, scope.Search.offset) return scope.Dialect().LimitAndOffsetSQL(scope.Search.limit, scope.Search.offset)
} }
@ -1020,7 +1023,7 @@ func (scope *Scope) count(value interface{}) *Scope {
scope.Search.Select("count(*)") scope.Search.Select("count(*)")
} }
} }
scope.Search.ignoreOrderQuery = true scope.Search.ignoreProcessingResult = true
scope.Err(scope.row().Scan(value)) scope.Err(scope.row().Scan(value))
return scope return scope
} }

View File

@ -5,25 +5,25 @@ import (
) )
type search struct { type search struct {
db *DB db *DB
whereConditions []map[string]interface{} whereConditions []map[string]interface{}
orConditions []map[string]interface{} orConditions []map[string]interface{}
notConditions []map[string]interface{} notConditions []map[string]interface{}
havingConditions []map[string]interface{} havingConditions []map[string]interface{}
joinConditions []map[string]interface{} joinConditions []map[string]interface{}
initAttrs []interface{} initAttrs []interface{}
assignAttrs []interface{} assignAttrs []interface{}
selects map[string]interface{} selects map[string]interface{}
omits []string omits []string
orders []interface{} orders []interface{}
preload []searchPreload preload []searchPreload
offset interface{} offset interface{}
limit interface{} limit interface{}
group string group string
tableName string tableName string
raw bool raw bool
Unscoped bool Unscoped bool
ignoreOrderQuery bool ignoreProcessingResult bool
} }
type searchPreload struct { type searchPreload struct {