Skip to content

Releases: vapor/fluent-kit

Add UInt8-backed enum test

26 Dec 17:13
877bf49

Choose a tag to compare

Pre-release

Adds a test to ensure models with UInt8-backed enum properties work properly.

Don't eager load on empty result set

26 Dec 16:33
27d8b35

Choose a tag to compare

Pre-release

Fluent's QueryBuilder no longer attempts to run eager loads if all() returns zero models. This fixes an issue where attempting to eager load children on a query that returned zero models would result in a syntax error (#117).

Duplicate constraint name fix

17 Dec 04:42
c232981

Choose a tag to compare

Pre-release
  • Constraint names (unique and foreign key) now include the table name (#112, #113)

  • Publicized Model.key(for:) method for getting field key strings statically (#113)

FluentKit 1.0.0 Beta 2.4

13 Dec 23:51
5a2fbd6

Choose a tag to compare

Pre-release
  • Fix array test to store json array as .array(of: .json) (#111)

FluentKit 1.0.0 Beta 2.3

11 Dec 04:02
2535037

Choose a tag to compare

Pre-release
  • Standardized eagerLoaded value on all relations. (#106, #109)

FluentKit 1.0.0 Beta 2.2

11 Dec 01:27
e77647e

Choose a tag to compare

Pre-release
  • Adds array(of:) case to DatabaseSchema.DataType (#105)
  • Adds test for model containing array fields (#105)
  • Adds a performance test to FluentBenchmarker (#105)

FluentKit 1.0.0 Beta 2.1

10 Dec 22:46

Choose a tag to compare

Pre-release
  • Fixes an operator precedence issue when querying on soft-deletable models. (#104)

FluentKit 1.0.0 Beta 2

09 Dec 18:50
5df66ee

Choose a tag to compare

Pre-release
  • Replaced Model lifecycle hooks with ModelMiddleware (#93)

The use of a middleware pattern for interacting with model lifecycle allows for greater control and flexibility. This also solves the longstanding issue of accessing shared state inside of lifecycle events. Now share state can be stored on the model middleware during app configuration.

Middleware also have the ability to change an event as it is passed through the middleware chain. For example, a middleware can intercept an update event and change it to a delete.

Multiple middleware can be configured to a single database. Additionally, AnyModelMiddleware can be used to create middleware for all Fluent models passing through a given DB.

Example:

// beta.1
final class User: Model {
    ...

    func didCreate(on db: Database) -> EventLoopFuture<Void> {
        print("user created")
    }
}

// beta.2
struct UserMiddleware: ModelMiddleware {
    func create(model: User, on db: Database, next: AnyModelResponder) -> EventLoopFuture<Void> {
        return next.create(model, on: db).map {
            print("user created")
        }
    }
}
  • Added foreign key support. (#83)

  • Publicized settable ID.exists for marking a model as already existing in the DB without fetching. (#94)

  • Fixed an issue when two children pointed to the same parent model. (#95)

  • Fixed an issue when create on an empty array of models (#97)

  • Enabled test discovery on Linux (#102)

FluentKit 1.0.0 Beta 1

24 Oct 21:34
2907bfd

Choose a tag to compare

Pre-release
  • Added a new @OptionalParent relation where the child's parent ID is optional. (#78)
  • filter operators now support comparing two columns. (#79)
  • Added a new protocol ModelAlias for handling queries that join a given table more than once. (#75)
final class Match: Model {
    ...

    @Parent(key: "home_team_id")
    var homeTeam: Team

    @Parent(key: "away_team_id")
    var awayTeam: Team
}

final class Team: Model {
    ...

    @Children(from: \.$homeTeam)
    var homeMatches: [Match]

    @Children(from: \.$awayTeam)
    var awayMatches: [Match]
}

struct HomeTeam: ModelAlias {
    typealias Model = Team
    static var alias: String { "home_teams" }
}

struct AwayTeam: ModelAlias {
    typealias Model = Team
    static var alias: String { "away_teams" }
}

let matches = try Match.query(on: self.database)
    .join(HomeTeam.self, on: \Match.$homeTeam == \Team.$id)
    .join(AwayTeam.self, on: \Match.$awayTeam == \Team.$id)
    .filter(HomeTeam.self, \Team.$name == "a")
    .all().wait()

for match in matches {
    let home = try match.joined(HomeTeam.self)
    let away = try match.joined(AwayTeam.self)
    print(match.name)
    print("home: \(home.name)")
    print("away: \(away.name)")
}
  • Database can now specify an EventLoopPreference and Logger. (#84)

This is in line with changes to how Vapor 4.0.0 Beta 1 handles services.

  • SchemaBuilder.update is now implemented.
  • Fixed an issue where @Children would serialize as an empty container if not eager loaded. (#70)
  • Fixed an issue preventing the sort method from called with a field key path. (#64)
  • Added support for accessing the cached model ID from @Children relations. (#71)

FluentKit 1.0.0 Alpha 3.1

11 Sep 20:04
bd98d1a

Choose a tag to compare

Pre-release
  • Fixes a bug causing @Parent.query and @Parent.get to filter on the wrong column. (#68)

Notes: Previously these methods would attempt to filter the related parent by the child's key. They now filter on the parent's key (identifier).