Releases: vapor/fluent-kit
1.48.0 - Primary Sendable support for Fluent
What's Changed
Primary Sendable support for Fluent by @gwynne in #601
Adds as much
Sendable
correctness to FluentKit as it is possible to add.[!IMPORTANT]
It was not possible to makeModel
correctlySendable
due to limitations of how property wrappers work, even though the wrappers themselves areSendable
. Users can get around this by adding@unchecked Sendable
to each individualModel
class, but this of course does not confer actual safety; it just disables the compiler’s warnings.Also adds some missing APIs to
FluentSQL
to allow encoding Fluent models to SQLKit queries. The existing APIs for decoding Fluent models from SQLKit queries have been renamed, and the old names deprecated.Other changes:
- The performance improvements for
Mirror
are now used in Swift 5.10QueryHistory
is no longer thread-unsafe for reading- The minimum supported Swift version is now 5.8
SomeCodingKey
is now an alias for SQLKit’s version
This patch was released by @gwynne
Full Changelog: 1.47.3...1.48.0
1.47.3 - Fix up FluentKit tests after SQLKit update
What's Changed
Fix up FluentKit tests after SQLKit update by @gwynne in #599
Also bumps Swift minimum to 5.7 and adds
ExistentialAny
compliance.
This patch was released by @gwynne
Full Changelog: 1.47.2...1.47.3
1.47.2 - Skip DB execution when all ids for @OptionalParent are nil
What's Changed
Skip DB execution when all ids for @OptionalParent are nil by @mtj0928 in #583
OptionalParentEagerLoader
doesn’t need to fetchTo
objects when all ids of the given models arenil
, because the results of the DB execution will always be empty.Therefore, I’ve modified the logic to skip the DB execution in such cases to improve performance.
New Contributor
This patch was released by @gwynne
Full Changelog: 1.47.1...1.47.2
1.47.1 - Explicitly set all columns when creating arrays of models
What's Changed
Explicitly set all columns when creating arrays of models by @gwynne in #595
When performing an insert query (the “create” model action), we now explicitly emit
DEFAULT
as the value for fields which have not been set. This ensures that when creating an array of models, the column count for each individual model is the same even if not all fields are set on each one, avoiding a fatal error.Fixes #594.
This patch was released by @gwynne
Full Changelog: 1.47.0...1.47.1
1.47.0 - Relax restrictions on ModelAlias use and join conditions
What's Changed
Relax restrictions on ModelAlias use and join conditions by @gwynne in #593
- Relaxes most of Fluent’s filter operators to only require
Schema
conformance rather thanModel
. This enablesModelAlias
usage with all operators that it previously didn’t work for.- Enables all model value filters in joins (e.g.
join(Foo.self, on: \Foo.$bar.$id == \Bar.$id && \Bar.$value > 4)
).- Adds
.sql(raw:)
,.sql(embed:)
, and.sql(_:)
for Fluent joins.(Note: Not a semver-major break because the new generic requirements on operators are always strict supersets of the old ones.)
This patch was released by @gwynne
Full Changelog: 1.46.0...1.47.0
1.46.0 - Add `@discardableResult` to QueryBuilder's range and sort methods
What's Changed
Add @discardableResult
to QueryBuilder's range and sort methods by @jiahan-wu in #592
This Pull Request addresses an issue where calling the sort methods in the QueryBuilder class would result in a “Result of call to ‘sort’ is unused” warning. To resolve this, I have added the @discardableResult attribute to these methods, allowing users to call them without triggering the warning when the result is not explicitly used.
This patch was released by @gwynne
Full Changelog: 1.45.1...1.46.0
1.45.1 - Make DatabaseID Sendable
What's Changed
Make DatabaseID Sendable by @adam-fowler in #590
Add Sendable conformance to
DatabaseID
.Make DatabaseID Sendable
This patch was released by @0xTim
Full Changelog: 1.45.0...1.45.1
1.45.0 - Allow pivot editing closures to be async and throwing.
What's Changed
Allow pivot editing closures to be async and throwing. by @gwynne in #585
When using the
attach(_:method:on:_:)
andattach(_:on:_:)
methods ofSiblingsProperty
, the optional closure provided to allow editing new pivots before they are saved can now optionally be boththrows
andasync
.Closes #581.
Additional changes:
- All versions of the
isAttached()
,attach()
, anddetach()
methods ofSiblingsProperty
will now throw errors (specifically cases of the newSiblingsPropertyError
enum) instead of callingfatalError()
when an unsaved model is encountered.
Reviewers
Thanks to the reviewers for their help:
This patch was released by @gwynne
Full Changelog: 1.44.1...1.45.0
1.44.1 - Correctly handle @OptionalEnum properties when using ~~ and != in filter()
What's Changed
Correctly handle @OptionalEnum properties when using ~~ and != in filter() by @gwynne in #580
We were incorrectly hardcoding the use of
.bind
query values when using the~~
(contains) and!~
(not contains) operators with properties having optional values in Fluentfilter()
expressions. This appears to be the only place where this was still happening.
Reviewers
Thanks to the reviewers for their help:
This patch was released by @gwynne
Full Changelog: 1.44.0...1.44.1
1.44.0 - Fully work around MySQL 5.7's lack of the DROP CONSTRAINT statement
What's Changed
Fully work around MySQL 5.7's lack of the DROP CONSTRAINT statement in #575
The work done in #522 added the ability to drop foreign keys when using a MySQL 5.7 database by enabling Fluent to generate the necessary
DROP FOREIGN KEY
syntax to make up for the old version's lack of the more standard and more flexibleDROP CONSTRAINT
statement.However, this still required users to specify the complete and current foreign key constraint definition at the time of deletion so Fluent could work out the correct "normalized" constraint identifier. These changes make it possible to also drop a foreign key constraint by name, requiring only the knowledge that it is, in fact, a foreign key.
Users wishing to drop foreign key constraints by name when using MySQL 5.7 must use the new API provided. Users of other versions of MySQL and other databases may also use the new API, or continue to use the old one.
New APIs added in this release:
FluentKit.DatabaseSchema.DeleteConstraint.namedForeignKey(_:)
: Specify a constraint deletion operation using a name and the explicit indication that the constraint to drop is a foreign key.FluentKit.SchemaBuilder.deleteForeignKey(name:)
: Add a constraint deletion for a foreign key with the given name to a schema builder invocation. Identical todeleteConstraint(name:)
except on MySQL 5.7.Fixes #491, vapor/fluent#722. Supersedes #492, #522.
This patch was released by @gwynne.
Full Changelog: 1.43.2...1.44.0