Releases: vapor/fluent-kit
Test benchmark updates
This patch was authored and released by @tanner0101.
FluentBenchmarker
now logs test names at .notice
and siblings performance tests use a single connection (#356).
Add QueryBuilder.fields(for: Model)
This patch was authored and released by @tanner0101.
Adds a new method to QueryBuilder
for fetching all fields from a given model (#354, fixes #346).
// Fetch all Planets with Star named "Sun"
let planets = Planet.query(on: req.db)
// Only fetch fields for Planet, even though
// Star is being joined.
.fields(for: Planet.self)
// Join Star model and use it to filter results.
.join(Star.self, on: \Planet.$star.$id == \Star.$id)
.filter(Star.self, \.$name == "Sun")
.all()
Fix @ID generation for nil values
This patch was authored and released by @tanner0101.
Fixes an issue causing .database
generated @ID
s to not generate values when set to nil
(#353).
This issue was caused by changes in 1.3.2 (#352). FluentBenchmarker
has been updated with a test that should catch this bug going forward.
Allow generated @IDs to be overridden
This patch was authored and released by @tanner0101.
Fixes a bug preventing @ID
properties generated by .database
(i.e., Int
type) from being overridden (#352, fixes #332).
Fix invalid @Enum value decode
This patch was authored and released by @tanner0101.
Decoding a model with invalid @Enum
or @OptionalEnum
values now throws an error instead of crashing (#351, fixes #350).
Add @Timestamp(key: "...", on: .none) functionality
This patch was authored by @gwynne and released by @tanner0101.
Adds new case .none
to TimestampTrigger
(#336).
Using TimestampTrigger.none
on a @Timestamp
property makes it act like a normal @OptionalField
, so that Fluent never updates the timestamp automatically. Such properties retain the ability to take advantage of TimestampFormat
s for explicitly defining the format of the timestamp value in the database.
Note: Technically, since this adds an enum
case, it would be a semver-major
change, breaking source compatibility for anyone switching over the TimestampTrigger
type. However, the expectation is doing this would be very rare.
Fix optional string contains operator
This patch was authored and released by @tanner0101.
Fixes SQL conversion for the ~~
operator when used with optional fields (fixes #329).
add Database.logging(to:) method
This patch was authored and released by @tanner0101.
Adds a new extension to Database
for overriding its logger (fixes #344, #345).
The example below shows how this API could be used to temporarily prevent errors from being logged.
app.post("users") { req in
let user: User = ...
// Make a copy of the request logger
// and change its log level
var copy = req.logger
copy.logLevel = .critical
// Use the logging(to:) method to create a
// temporary Database with the new logger
return user.save(
on: req.db.logging(to: copy)
)
}
Add missing join filter overload
This patch was authored and released by @tanner0101.
Adds a missing overload for filtering joined models (#342, fixes #310).
Adds method for appending models to ArrayTestDatabase
(#342).
Disallows private-scoped migrations with default names.
This patch was authored and released by @mattpolzin.
Migrations with unstable names can no longer be applied (fixes #327).
Migrations with private
scope and a default name will result in a fatal error now. If you run into this fatal error, there are two solutions:
- Make the migration
public
orinternal
. - Give the migration an explicit name:
struct example: Migration {
let name: String = "SomeUniqueNameHere"
...
}