dialect/sql: append UNION before ORDER BY (#1761)

* fix: builder to append UNION before ORDER_BY

* gofmt builder_test.go
This commit is contained in:
Khadija Sidhpuri
2021-07-23 02:03:34 +05:30
committed by GitHub
parent 444b5f57b9
commit 364ab46333
2 changed files with 15 additions and 3 deletions

View File

@@ -2320,6 +2320,9 @@ func (s *Selector) Query() (string, []interface{}) {
b.WriteString(" HAVING ")
b.Join(s.having)
}
if len(s.union) > 0 {
s.joinUnion(&b)
}
if len(s.order) > 0 {
s.joinOrder(&b)
}
@@ -2331,9 +2334,6 @@ func (s *Selector) Query() (string, []interface{}) {
b.WriteString(" OFFSET ")
b.WriteString(strconv.Itoa(*s.offset))
}
if len(s.union) > 0 {
s.joinUnion(&b)
}
s.joinLock(&b)
s.total = b.total
s.AddError(b.Err())