Skip to content

Commit 2c1dd3b

Browse files
committed
query union with parentheses
1 parent ac9c37b commit 2c1dd3b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

orm/query_select_gen.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,13 @@ func (q *Query[T]) generateSelectQuery(columns ...any) *SubQuery {
117117
}
118118

119119
if len(q.unions) > 0 {
120+
rawSql = "(" + rawSql + ")"
120121
for _, v := range q.unions {
121122
prefix := "\nunion"
122123
if v.unionAll {
123124
prefix += " all"
124125
}
125-
prefix += " \n" + v.raw
126+
prefix += " \n" + "(" + v.raw + ")"
126127
rawSql += prefix
127128
bindings = append(bindings, v.bindings...)
128129
}

0 commit comments

Comments
 (0)