Skip to content

Releases: vapor/fluent-kit

1.53.0 - Add Service Lifecycle Support

08 Dec 00:32
0272fda

Choose a tag to compare

What's Changed

Add Service Lifecycle Support by @0xTim in #646

Adds support for Swift Service Lifecycle as we prepare Vapor for Vapor 5.

This allows you to add Databases to a ServiceGroup and have service lifecycle handle shutting down the connection pool when the application exits and provides a better integration with the ecosystem.

This patch was released by @0xTim

Full Changelog: 1.52.2...1.53.0

1.52.2 - Fix arithmetic overflow crash in request pagination

08 May 23:09
8baacd7

Choose a tag to compare

What's Changed

Fix arithmetic overflow crash in request pagination by @petrpavlik in #637

When paging request, providing large values for page and per params will cause an arithmetic overflow exception and crash the process

Fixes a crash where trying to paginate with values that when multiplied cause an arithmetic overflow exception and crash the process. Following added unit tests provides an example.

    func testPaginationDoesntCrashOnOverflow() throws {
        let db = DummyDatabaseForTestSQLSerializer()
        let pageRequest1 = PageRequest(page: 1184467440737095516, per: 1184467440737095516)
        db.fakedRows.append([.init(["aggregate": 1])])
        // This would crash on `Swift runtime failure: arithmetic overflow` if not handled
        // so no point trying any XCTAssert
        _ = try Planet2
            .query(on: db)
            .paginate(pageRequest1)
            .wait()
    }
This patch was released by @gwynne

Full Changelog: 1.52.1...1.52.2

1.52.1 - Slightly improve the way database queries are represented in logging metadata

14 Apr 12:36
1385c48

Choose a tag to compare

What's Changed

Slightly improve the way database queries are represented in logging metadata by @gwynne in #635

While this has no visible impact when using the “default” StreamLogHandler, it becomes quite visible when using smarter log handlers which respect the structural representation afforded by Logger.MetadataValue.

For example, with StreamLogHandler, with or without these changes, a given query might get logged like this:

2025-04-14T06:53:04-0500 debug test : action=update filters=["[\"relation\": \"and\", \"group\": \"[\\\"[\\\\\\\"value\\\\\\\": \\\\\\\"00000000-0000-0000-0000-000000000000\\\\\\\", \\\\\\\"field\\\\\\\": \\\\\\\"composite+planet.system_id\\\\\\\", \\\\\\\"method\\\\\\\": \\\\\\\"=\\\\\\\"]\\\", \\\"[\\\\\\\"field\\\\\\\": \\\\\\\"composite+planet.nrm_ord\\\\\\\", \\\\\\\"method\\\\\\\": \\\\\\\"=\\\\\\\", \\\\\\\"value\\\\\\\": \\\\\\\"1\\\\\\\"]\\\"]\"]"] input=["[\"name\": \"AA\"]"] limits=[] offsets=[] schema=composite+planet sorts=[] [FluentKit] Running query

With a smarter log handler (an only slightly modified version of StreamLogHandler in fact), but without these changes, it looks like t…

Reviewers

Thanks to the reviewers for their help:

This patch was released by @gwynne

Full Changelog: 1.52.0...1.52.1

1.52.0 - Remove the spurious dependency on AsyncKit

13 Apr 12:16
0f1b8bf

Choose a tag to compare

What's Changed

Remove the spurious dependency on AsyncKit by @gwynne in #634

Although each of the Fluent database drivers depends on AsyncKit for (poor) connection pooling, FluentKit itself does not need any of AsyncKit‘s services. It was only being used for some simple EventLoopFuture utilities, and wasn’t even being reexported (thankfully). This removes the completely unnecessary dependency altogether.

Additional changes:

  • The minimum required Swift version is now 5.10
  • The code is now MemberImportVisibility-correct
  • The MirrorBypass logic is now enabled in Swift 6.1

Reviewers

Thanks to the reviewers for their help:

This patch was released by @gwynne

Full Changelog: 1.51.0...1.52.0

1.51.0 - Add the missing `.sql()` helpers for various DatabaseQuery types to FluentSQL

29 Mar 17:33
788f4b9

Choose a tag to compare

What's Changed

Add the missing .sql() helpers for various DatabaseQuery types to FluentSQL by @gwynne in #633

Adds .sql(unsafeRaw:), .sql(embed:), and .sql(_:) helpers for the following types to FluentSQL:

  • DatabaseQuery.Action
  • DatabaseQuery.Aggregate
  • DatabaseQuery.Aggregate.Method
  • DatabaseQuery.Filter.Method
  • DatabaseQuery.Filter.Relation
  • DatabaseQuery.Join.Method
  • DatabaseQuery.Sort.Direction

Additional changes:

  • Schema.spaceIfNotAliased is now public (it was previously internal).
  • Updated the minimum version requirements for a couple of dependencies and made the FluentKit target’s product dependencies more explicit.
  • DatabaseQuery.Limit.custom(_:) and DatabaseQuery.Offset.custom(_:) are now deprecated, reflecting the fact that any use of them causes an unconditional fatalError(). Due to design limitations in SQLKit, it is not possible to implement them correctly instead of erroring.
  • As promised, the use of @_spi has been removed in favor of the package access modifier now that we require Swift 5.9. This removes public symbols from the API, but because those symbols were SPI and had been explicitly documented as becoming non-public…

Reviewers

Thanks to the reviewers for their help:

This patch was released by @gwynne

Full Changelog: 1.50.4...1.51.0

1.50.4 - Partial fix for nested keypaths through `@CompositeOptionalParent` properties

12 Mar 00:14
f12a668

Choose a tag to compare

What's Changed

Partial fix for nested keypaths through @CompositeOptionalParent properties by @gwynne in #632

As with @CompositeParent, keypaths through @CompositeOptionalParent can refer to properties of the target model’s composite IDValue. However, the subscript(dynamicMember:) accessor of @CompositeOptionalParent which enables this functionality returns an optional value, and the result is always nil if the relation has not been loaded.

This was caused by an oversight during the original implementation of the composite relation properties: The accessor should not be returning an optional value, nor should the result ever be nil regardless of whether or not the relation is loaded. We can’t fix the fact that it returns an optional without breaking public API, so callers still have to add a ! in the nested keypaths. But we can at least make the accessor useful by fixing it to never return nil, which is what this PR does. A test is also included.

Also updates the CI while we’re at it.

final class ParentModel: Model, @unchecked Sendable {
    final class IDValue: Fields, @unc

This patch was released by @gwynne

Full Changelog: 1.50.3...1.50.4

1.50.3 - Enable the MirrorBypass logic in Swift 6

18 Feb 04:00
4f886eb

Choose a tag to compare

What's Changed

Enable the MirrorBypass logic in Swift 6 by @gwynne in #631

It turns out that the “bypass” for Mirror works fine in Swift 6, so let’s use it.

Reviewers

Thanks to the reviewers for their help:

This patch was released by @gwynne

Full Changelog: 1.50.2...1.50.3

1.50.2 - fix: handle nil CompositeIDProperty value during database insert

07 Feb 05:00
dd5a92d

Choose a tag to compare

What's Changed

fix: handle nil CompositeIDProperty value during database insert by @bwdmr in #628

The CompositeIDProperty was force-unwrapping its value during database input, which would crash if the value was nil. This could happen during initial inserts where the composite ID is meant to be set by a database trigger. Now checks if value exists before attempting to input it.

This patch was released by @gwynne

Full Changelog: 1.50.1...1.50.2

1.50.1 - Be more specific about which model's ID property is missing in error message

29 Jan 13:00
153c495

Choose a tag to compare

What's Changed

Be more specific about which model's ID property is missing in error message by @gwynne in #626

If a model’s id property is missing or incorrectly declared, the fatalError() which is triggered now includes the name of the model in question.

This patch was released by @gwynne

Full Changelog: 1.50.0...1.50.1

1.50.0 - Fix Fluent model encoding for SQLKit and several Sendable warnings

16 Jan 11:15
260eff9

Choose a tag to compare

What's Changed

Fix Fluent model encoding for SQLKit and several Sendable warnings by @gwynne in #624

Full change list:

  • Require Swift 5.9
  • Resolve several new Sendable-related warnings
  • Fix an issue which caused unpredictable failures when encoding multiple Fluent models for SQLKit queries due to unstable column ordering.
  • Fix NIO API (EmbeddedEventLoop) misuse in tests
  • Disable unfixable flaky test
This patch was released by @gwynne

Full Changelog: 1.49.0...1.50.0