Skip to content

ORDER BY mixed with UNION doesn't render properly

Description

ORDER BY with the first SELECT doesn't put the ORDER BY after the UNION. Also, there's again an extra comma after the second order by column.

Steps to Reproduce

Select(N("Col", as: "c")).from(N("Table", as: "t"))
    .union(
        Select().from("OneColTable")
        .where(OP("ID")-!?)
    )
    .orderBy("col1", "col2").description
// SELECT Col AS c FROM Table AS t ORDER BY col1, col2, UNION SELECT * FROM OneColTable WHERE ID IS NOT NULL