Skip to content

Releases: vapor/fluent-kit

Add eager loading for pivots on sibling relationships

26 Oct 14:58
f0cc72a
Compare
Choose a tag to compare
This patch was authored and released by @JaapWijnen.

Adds support for eager loading of pivots on sibling relationships.

This is useful if there is extra information stored on the pivot itself that is relevant for the relationship itself instead of the models connected by it.

Example (using the planet <-> tag relation from the docs):

Planet.query(on: req.db).with(\.$tags).with(\.$tags.$pivots).first() { planet in 
   // you can now access the loaded pivots using:
   let pivots = planet.$tags.pivots
}

Don't Re-Delete Soft-Deleted Models

23 Oct 19:40
50d001b
Compare
Choose a tag to compare
This patch was authored and released by @calebkleveter.

Soft-deleted models will no longer be re-deleted (have their .deleteAt values updated), when they are included in a DELETE query.

Closes #388
Closes #389

Require value for @Parent when eager loaded

27 Aug 20:00
ef2a9a7
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Queries that fail to eager-load a value for a @Parent relation will now throw an error (#380).

This change helps prevent unintended access of uninitialized @Parent properties in cases where no parent is found. For example, if the parent is deleted (including soft-deletion) or the reference was set to an invalid identifier.

Minimum iOS version is 13

21 Aug 21:42
8f72367
Compare
Choose a tag to compare
This patch was authored and released by @calebkleveter.

The minimum iOS version supported by this package is now iOS 13 since ISO8601DateFormatter requires it to be version 10 and 13 matches the Catalina requirement.

Support disabling foreign key checks in benchmarker

06 Aug 20:43
2227231
Compare
Choose a tag to compare
This patch was authored by @valeriomazzeo and released by @tanner0101.

Adds flag for disabling foreign key checks in FluentBenchmarker (#368).

In #364 testSchema_fieldReference has been introduced. Drivers like mongo don't support foreign key constraints which causes the above FluentBenchmark test to fail.

Although, an effort has been made to partially supports Fluent schema features by using mongo schema validation this specific feature it's still not supported.

Add raw query model decode helper

06 Aug 20:16
3bcff79
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Adds helper methods to SQLRow and SQLDatabase query builders for decoding models (#362, fixes #334).

guard let sql = req.db as? SQLDatabase else { ... }
let users = sql.raw("SELECT * FROM users").all(decoding: User.self)

Both first and all are available on SQLDatabase as well as decode on SQLRow.

let row: SQLRow = ...
let user = try row.decode(model: User.self)

These overloads work by circumventing model's Codable conformance and decoding the SQL row as database output.

Note: Some features of Model, like model.joined(_:), may not work correctly when decoding from SQLKit directly as they rely on specific key naming.

Add SQLConverterDelegate.beforeConvert method

29 Jul 01:27
8a20f1d
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Adds SQLConverterDelegate.beforeConvert method (#364).

This is mostly an internal change and allows for SQLConverterDelegate conformers to alter the DatabaseSchema before it is converted to SQLKit expressions.

Additionally, a FluentBenchmarker test has been added to ensure that the .references field constraint is being enforced by drivers.

Simplify benchmark pooling + CI

23 Jul 19:17
6276711
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Internal changes only. Simplifies benchmark test pooling and CI (#361).

Support @Enum usage in QueryBuilder.set

22 Jul 16:46
5ae2c3f
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Fixes an issue causing QueryBuilder.set to improperly bind @Enum values (#360, fixes #357).

Add join methods for @Parent, @Children, and @Siblings

22 Jul 14:55
a26c562
Compare
Choose a tag to compare
This patch was authored by @MatsMoll and released by @tanner0101.

Adds new methods to QueryBuilder for easily joining @Parent, @Children, and @Siblings relations. (#338)

Planet.query(on: db)
   // Joins the Star table
    .join(parent: \.$star)
   // Joins the Galaxy table based based on the joined Star table
    .join(from: Star.self, parent: \.$galaxy)
    .filter(Galaxy.self, \.$id == galaxyID)
    .unique()
   // Returns all Planet's in the galaxy with id `galaxyID`
    .all()