版本发布 8
## What's Changed Add the missing `SQLDatabase.alter(table: any SQLExpression)` method by @gwynne in #188 > Each of the various query builders have overloads on `SQLDatabase` which accept `any SQLExpression` parameters, except for `SQLAlterTableQueryBuilder`. The missing `SQLDatabase.alter(table: any SQLExpression)` overload is now provided. > > Additional changes: > > - Fixed several minor issues in the API docs. > - The minimum required Swift version is now 5.10. ## Reviewers Thanks to the reviewers for their help: - @MahdiBM ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.32.0...3.33.0
## What's Changed Adds multirow insert method by @NeedleInAJayStack in #153 > This adds functionality to do a multi-row inserts with a single `values` method call. > > Previously, to insert multiple rows a user had to call `values` repeatedly: > > ```swift > db.insert(into: "planets") > .columns(["name", "color"]) > .values([SQLBind("Jupiter"), SQLBind("orange")]) > .values([SQLBind("Mars"), SQLBind("red")]) > .run() > ``` > > This was a bit awkward when inserting rows from an array, where an instance of the builder had to be saved off and edited: > > ```swift > let rows: [[SQLExpression]] = [[...], [...], ...] > let builder = db.insert(into: "planets") > .columns(["name", "color"]) > for row in rows { > builder.values(row) > } > builder.run() > ``` > > ```swift > db.insert(into: "planets") > .columns(["name", "color"]) > .values([[SQLBind("Jupiter"), SQLBind("orange")], [SQLBind("Mars"), SQLBind("red")]]) > .run() > > let rows = [[...], [...], ...] > db.insert(into: "planets") > .columns(["name", "color"]) > .values(rows) > .run() > ``` > … ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.31.1...3.32.0
## What's Changed Fix behavior of SQLColumn when "*" is specified as a column name by @gwynne in #181 > This behavior was implemented in `SQLUnqualifiedColumnListBuilder` but actually belonged in `SQLColumn` itself. Thanks @ptoffy! > > Fixes #180. ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.31.0...3.31.1
## What's Changed Add support for Common Table Expressions by @gwynne in #179 > CTEs (`WITH` clauses) are now supported by `SELECT`, `INSERT`, `UPDATE`, `DELETE`, and `UNION` queries, including subqueries. Test and docs coverage is 100%. ## Reviewers Thanks to the reviewers for their help: - @MahdiBM ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.30.0...3.31.0
## 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 original `SQLUnion` implementation, the usage is slightly awkward. Example usage: > > ```swift > 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: > > ```sql > 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 using `SQLSubquery.select(_:)`; the call chain must start with `SQLSubquery.union(_:)`. ## Reviewers Thanks to the reviewers for their help: - @MahdiBM ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.29.3...3.30.0
## What's Changed Relax minimum dependency version for swift-collections by @gwynne in #177 > Downstream users of SQLKit who also depend on [SwiftPM](https://github.com/apple/swift-package-manager) currently experience a dependency conflict with `swift-collections` due to SwiftPM’s restrictive allowed version range. Since SQLKit doesn’t actually need the newest `swift-collections`, we can solve this by simply reducing SQLKit’s minimum required version. > > Also removes a spurious dependency on `swift-docc-plugin` which was accidentally left in place during the 3.29.0 release. ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.29.2...3.29.3
## What's Changed Fix overhaul breakage, part 2 by @gwynne in #176 > This solves the source code breakage issue first reported in #175 - shout out and thanks to @NeedleInAJayStack for reporting the problem! > > Several preexisting APIs had incorrectly changed from accepting `any Encodable` to accepting `some Encodable`, which is source-breaking under some conditions. This restores the original use of `any` (though it keeps the added `Sendable` requirement). > > Also restores 100% test coverage after the previous fixes. > > > [!NOTE] > > Many APIs which had previously accepted a generic parameter (i.e. `<E: Encodable>`), most notably in `SQLPredicateBuilder`, also switched to using `some Encodable`, but this was not source-breaking; the problem applied only to APIs which originally accepted `any Encodable`. > > > > Although the changes in this PR are technically themselves source-breaking, since they revert a previous such breakage to its previous state, only a `semver-patch` bump is necessary. ###### _This patch was released by @gwynne_ **Full Changelog**: https://github.com/vapor/sql-kit/compare/3.29.1...3.29.2
Fixes some issues that broke building against FluentKit when not using any of the driver packages. Also adds CI to test this scenario.