Fix tests
This commit is contained in:
parent
f3a0fc1566
commit
d7ef7871a4
@ -18,7 +18,7 @@ func queryCallback(scope *Scope) {
|
|||||||
if _, skip := scope.InstanceGet("gorm:skip_query_callback"); skip {
|
if _, skip := scope.InstanceGet("gorm:skip_query_callback"); skip {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//we are only preloading relations, dont touch base model
|
//we are only preloading relations, dont touch base model
|
||||||
if _, skip := scope.InstanceGet("gorm:only_preload"); skip {
|
if _, skip := scope.InstanceGet("gorm:only_preload"); skip {
|
||||||
return
|
return
|
||||||
|
9
main.go
9
main.go
@ -178,7 +178,13 @@ func (s *DB) SingularTable(enable bool) {
|
|||||||
func (s *DB) NewScope(value interface{}) *Scope {
|
func (s *DB) NewScope(value interface{}) *Scope {
|
||||||
dbClone := s.clone()
|
dbClone := s.clone()
|
||||||
dbClone.Value = value
|
dbClone.Value = value
|
||||||
return &Scope{db: dbClone, Search: dbClone.search, Value: value}
|
scope := &Scope{db: dbClone, Value: value}
|
||||||
|
if s.search != nil {
|
||||||
|
scope.Search = s.search.clone()
|
||||||
|
} else {
|
||||||
|
scope.Search = &search{}
|
||||||
|
}
|
||||||
|
return scope
|
||||||
}
|
}
|
||||||
|
|
||||||
// QueryExpr returns the query as expr object
|
// QueryExpr returns the query as expr object
|
||||||
@ -298,6 +304,7 @@ func (s *DB) Assign(attrs ...interface{}) *DB {
|
|||||||
func (s *DB) First(out interface{}, where ...interface{}) *DB {
|
func (s *DB) First(out interface{}, where ...interface{}) *DB {
|
||||||
newScope := s.NewScope(out)
|
newScope := s.NewScope(out)
|
||||||
newScope.Search.Limit(1)
|
newScope.Search.Limit(1)
|
||||||
|
|
||||||
return newScope.Set("gorm:order_by_primary_key", "ASC").
|
return newScope.Set("gorm:order_by_primary_key", "ASC").
|
||||||
inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
|
inlineCondition(where...).callCallbacks(s.parent.callbacks.queries).db
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user