forked from mirror/gorm
Fix tests
This commit is contained in:
parent
f3a0fc1566
commit
d7ef7871a4
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…
Reference in New Issue