Skip to content

Releases: vapor/fluent-kit

Require SQLKit 3.1.0

02 Jun 19:51
0b6303c
Compare
Choose a tag to compare
Require SQLKit 3.1.0 Pre-release
Pre-release
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

30 May 14:46
67b737e
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.
  • Adds an overload of Migrations.add(_:to:) which accepts an array of Migration, 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

29 May 21:30
9e2f782
Compare
Choose a tag to compare
FluentKit 1.0.0 GM Pre-release
Pre-release
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 to nil.
  • .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).

DecodingErrors thrown by Model now include key path information.

Several small bug and convenience API fixes (#270).

Track Migrations Per Database

18 May 17:03
27288c2
Compare
Choose a tag to compare
Pre-release
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

06 May 18:54
c73570c
Compare
Choose a tag to compare
Pre-release
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

01 May 14:43
36d8ba6
Compare
Choose a tag to compare
This patch was authored by @123FLO321 and released by @tanner0101.
  • Fixes updated timestamp being updated when model doesn't have changes (#263).
  • Adds tests for model.hasChanges (#263).
  • Adds tests to test updates without changes on models with @Timestamp (#263).

Publicize NestedProperty and DatabaseOutput utilities

01 May 14:41
ca8f9b1
Compare
Choose a tag to compare
This patch was authored by @123FLO321 and released by @tanner0101.
  • Makes NestedProperty Initializer public (#262).
  • Makes DatabaseOutput cascading and nested functions public (#262).

Fix inverse subset serialization

24 Apr 15:04
c92320b
Compare
Choose a tag to compare
Pre-release
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

22 Apr 22:34
4def1ab
Compare
Choose a tag to compare
This patch was authored and released by @mcdappdev.

Removes a warning when nesting multiple query.group(relation:) calls

Query Builder Soft Delete

21 Apr 18:17
85fefee
Compare
Choose a tag to compare
Pre-release

Adds a new force parameter to QueryBuilder delete calls:

MyModel.query(on: db).filter(\.$name == "Vapor").delete(force: true)

⚠️ The default behavior of delete on QueryBuilder has changed. If the model is soft deletable the query builder will now honor this instead of force deleting.