Fixed limit and offset for subquery

This commit is contained in:
Gerhard Gruber 2021-11-23 15:04:56 +01:00
parent 30f2304e9d
commit edbcbe3126

View File

@ -188,7 +188,7 @@ func (s *DB) QueryExpr(alias ...string) *expr {
// SubQuery returns the query as sub query // SubQuery returns the query as sub query
func (s *DB) SubQuery() *expr { func (s *DB) SubQuery() *expr {
if s.search.limit == nil && s.search.offset == nil { if (s.search.limit == nil || s.search.limit == -1) && (s.search.offset == nil || s.search.offset == -1) {
s = s.Order(nil, true) s = s.Order(nil, true)
} }
scope := s.NewScope(s.Value) scope := s.NewScope(s.Value)