Skip to content

Releases: vapor/fluent-kit

Test benchmark updates

17 Jul 23:35
Compare
Choose a tag to compare
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)

15 Jul 17:31
7f704e7
Compare
Choose a tag to compare
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

15 Jul 13:40
c181c80
Compare
Choose a tag to compare
This patch was authored and released by @tanner0101.

Fixes an issue causing .database generated @IDs 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

14 Jul 19:58
3eacd5a
Compare
Choose a tag to compare
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

14 Jul 18:54
5166946
Compare
Choose a tag to compare
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

14 Jul 18:37
26b08df
Compare
Choose a tag to compare
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 TimestampFormats 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

14 Jul 17:25
9e618f6
Compare
Choose a tag to compare
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

13 Jul 16:21
4fa61e2
Compare
Choose a tag to compare
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

10 Jul 18:06
545a1b7
Compare
Choose a tag to compare
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.

06 Jul 16:33
c9d8cf2
Compare
Choose a tag to compare
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:

  1. Make the migration public or internal.
  2. Give the migration an explicit name:
struct example: Migration {
    let name: String = "SomeUniqueNameHere"
    ...
}