Releases: vapor/fluent-kit
1.53.0 - Add Service Lifecycle Support
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
Databasesto aServiceGroupand 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
What's Changed
Fix arithmetic overflow crash in request pagination by @petrpavlik in #637
When paging request, providing large values for
pageandperparams will cause an arithmetic overflow exception and crash the processFixes 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
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 byLogger.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 queryWith a smarter log handler (an only slightly modified version of
StreamLogHandlerin 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
What's Changed
Remove the spurious dependency on AsyncKit by @gwynne in #634
Although each of the Fluent database drivers depends on
AsyncKitfor (poor) connection pooling,FluentKititself does not need any ofAsyncKit‘s services. It was only being used for some simpleEventLoopFutureutilities, 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
MirrorBypasslogic 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
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.ActionDatabaseQuery.AggregateDatabaseQuery.Aggregate.MethodDatabaseQuery.Filter.MethodDatabaseQuery.Filter.RelationDatabaseQuery.Join.MethodDatabaseQuery.Sort.DirectionAdditional changes:
Schema.spaceIfNotAliasedis nowpublic(it was previouslyinternal).- Updated the minimum version requirements for a couple of dependencies and made the
FluentKittarget’s product dependencies more explicit.DatabaseQuery.Limit.custom(_:)andDatabaseQuery.Offset.custom(_:)are now deprecated, reflecting the fact that any use of them causes an unconditionalfatalError(). Due to design limitations in SQLKit, it is not possible to implement them correctly instead of erroring.- As promised, the use of
@_spihas been removed in favor of thepackageaccess 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
What's Changed
Partial fix for nested keypaths through @CompositeOptionalParent properties by @gwynne in #632
As with
@CompositeParent, keypaths through@CompositeOptionalParentcan refer to properties of the target model’s compositeIDValue. However, thesubscript(dynamicMember:)accessor of@CompositeOptionalParentwhich enables this functionality returns an optional value, and the result is alwaysnilif 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
nilregardless 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 returnnil, 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
What's Changed
Enable the MirrorBypass logic in Swift 6 by @gwynne in #631
It turns out that the “bypass” for
Mirrorworks 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
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
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
idproperty is missing or incorrectly declared, thefatalError()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
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