3.30.0 - Support the use of unions in subqueries
What's Changed
Support the use of unions in subqueries by @gwynne in #178
Adds support for the use of
UNION
queries within subqueries. Unfortunately, thanks to iffy design choices on my part in the originalSQLUnion
implementation, the usage is slightly awkward. Example usage:try await db.update("foos") .set(SQLIdentifier("bar_id"), to: SQLSubquery .union { $0 .column("id") .from("bars") .where("baz", .notEqual, "bamf") } .union(all: { $0 .column("id") .from("bars") .where("baz", .equal, "bop") }) .finish() ) .run()This generates the following query:
UPDATE "foos" SET "bar_id" = ( SELECT "id" FROM "bars" WHERE "baz" <> "bamf" UNION ALL SELECT "id" FROM "bars" WHERE "baz" = "bop" )Unfortunately, it is not possible to chain
.union()
when usingSQLSubquery.select(_:)
; the call chain must start withSQLSubquery.union(_:)
.
Reviewers
Thanks to the reviewers for their help:
This patch was released by @gwynne
Full Changelog: 3.29.3...3.30.0