Skip to content

Commit

Permalink
BUGFIX: don't auto add parentheses for union (#192)
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorchu authored Oct 15, 2019
1 parent 2b0519c commit 7fac565
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 3 additions & 1 deletion interpolate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ func TestInterpolateForDialect(t *testing.T) {
Select("b").From("table2"),
).As("t"),
},
want: "((SELECT a FROM table1) UNION ALL (SELECT b FROM table2)) AS `t`",
// parentheses around union subqueries are not supported in sqlite
// but supported in both mysql and postgres.
want: "(SELECT a FROM table1 UNION ALL SELECT b FROM table2) AS `t`",
},
{
query: "?",
Expand Down
6 changes: 4 additions & 2 deletions union.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,10 @@ func (u *union) Build(d Dialect, buf Buffer) error {
buf.WriteString("ALL ")
}
}
buf.WriteString(placeholder)
buf.WriteValue(b)
err := b.Build(d, buf)
if err != nil {
return err
}
}
return nil
}
Expand Down

0 comments on commit 7fac565

Please sign in to comment.