Releases: vapor/fluent-kit
Require SQLKit 3.1.0
This patch was authored and released by @tanner0101.
The previous tag used new API added in SQLKit 3.1.0. This release bumps the version requirement for that package to prevent build errors if swift package update
is not run.
Add helper methods for adding multiple Migrations at once
This patch was authored and released by @gwynne.
-
Adds an overload of
Migrations.add(_:to:)
which accepts an array ofMigration
, e.g.:app.migrations.add([ConfigModel.Migration(), SolarSystem.Migration()]) app.migrations.add([UserModel.Migration(), PostModel.Migration()], to: .psql)
As a new public API, this requires a
semver-minor
release. -
Also adds an overload which accepts a variadic parameter of
Migration
type:app.migrations.add(ConfigModel.Migration(), SolarSystem.Migration()) app.migrations.add(UserModel.Migration(), PostModel.Migration(), to: .psql)
-
Adds a benchmark test for the new methods, just for the heck of it.
FluentKit 1.0.0 GM
This patch was authored and released by @tanner0101.
Given the large number of fixes currently on the gm
branch, I've decided to release them as a final rc
version now. The official 1.0.0 will release will come as soon as the docs for Fluent are finished.
Unify field key path semantics (#268).
Makes FieldKey
path usage consistent across all db driver types. SQL no longer treats field key paths differently than NoSQL. This means @Group
now always serializes as a flat structure. Support for nested structures and dynamic structuring behavior between NoSQL and SQL will be added in the future with a more reliable design.
Improve property protocols (#268).
FieldProtocol
and PropertyProtocol
have been cleaned up and split into more descriptive protocols:
AnyProperty
AnyDatabaseProperty
AnyCodableProperty
AnyQueryableProperty
Property
QueryableProperty
Add Database.inTransaction
(fixes #23, #119).
Database drivers are expected to keep track of whether they are already in a transaction and not start a new one if they do not supported nested transactions. Users can check if the database they are using is currently in a transaction using the inTransaction
flag.
Fix issues filtering and setting @OptionalField
when nil
(#270).
@OptionalField.value
is now a double optional again. This was previously changed to avoid double optionals which can be tricky to work with, but a single optional does not accurately convey all states an @OptionalField
can be in:
nil
: Uninitialized.some(nil)
: Initialized tonil
..some(.some)
: Initialized to a value.
Furthermore, @OptionalField
's associated value type being an optional is required for generic operators (like ==
) and methods (like set(_:to:)
to properly accept nil
values.
Add batch delete method on collection of models (#270, fixes #114).
A new method delete(force:on:)
is now available on collections of models.
let earth: Planet = ...
let mars: Planet = ...
[earth, mars].delete(on: db)
Schema update constraints (#270, fixes #235).
Schema constraints can now be created and deleted during SchemaBuilder.update()
.
database.schema("planets")
.unique(on: "name")
.update()
Add constraint names (#270, fixes #118).
New methods on SchemaBuilder
are now available for naming unique and foreign key constraints.
database.schema("planets")
.field("name", .string, .required)
.unique(on: "name", name: "name_index")
Constraints can now be deleted by name as well.
database.schema("planets")
.deleteConstraint(name: "name_index")
Arbitrary join(_:on:)
ordering (#270, fixes #128).
QueryBuilder.join
's on
parameter can now have fields appear on either side of ==
.
School.query(on: self.database)
.join(City.self, on: \School.$city.$id == \City.$id)
// or
.join(City.self, on: \City.$id == \School.$city.$id)
Add EnumBuilder.read()
(#270, fixes #194).
EnumBuilder
now supports reading the enum metadata outside of create()
. This is useful for re-using enums between schemas.
database.enum("planet_type").read().flatMap { planetType in
database.schema("planets")
.field("type", planetType)
.create()
}
Improve readability of Codable errors (#270, fixes #231).
DecodingError
s thrown by Model
now include key path information.
Several small bug and convenience API fixes (#270).
Track Migrations Per Database
This patch was authored and released by @calebkleveter.
Migrations are now tracked on the database they are run on, instead of all migrations being tracked on the default database. This resolves bugs that could occur when running the same migration on multiple databases.
Fix setting nil on @OptionalField
This patch was authored and released by @tanner0101.
Fixes an issue where setting an @OptionalField
to nil
would not save to the database (#267).
Fixes timestamp update when model doesn't have changes
This patch was authored by @123FLO321 and released by @tanner0101.
Publicize NestedProperty and DatabaseOutput utilities
This patch was authored by @123FLO321 and released by @tanner0101.
Fix inverse subset serialization
This patch was authored by @mcdappdev and released by @tanner0101.
Adds a fix for subset serialization when the RHS is empty (#258, fixes #257).
Add discardableResult to QueryBuilder.group
This patch was authored and released by @mcdappdev.
Removes a warning when nesting multiple query.group(relation:)
calls
Query Builder Soft Delete
Adds a new force parameter to QueryBuilder delete calls:
MyModel.query(on: db).filter(\.$name == "Vapor").delete(force: true)