Releases: vapor/fluent-kit
Add eager loading for pivots on sibling relationships
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
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.
Require value for @Parent when eager loaded
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
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
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
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
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
This patch was authored and released by @tanner0101.
Internal changes only. Simplifies benchmark test pooling and CI (#361).
Support @Enum usage in QueryBuilder.set
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
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()