Releases: vapor/fluent-kit
Enforce correct @ID(key:) usage at compile time
This patch was authored and released by @gwynne.
Using @ID(key:)
with a key other than .id
or a value that is not a UUID
is now a compile-time error instead of a runtime crash.
Additional changes:
- The legacy
@ID(key: "id")
syntax, where the key is specified as a string rather than using the.id
enumeration case, is hard-deprecated. Replace such usages with@ID(key: .id)
. This deprecation does not apply to custom IDs. - The
@ID(key: .id)
syntax is now considered soft-deprecated.@ID
is now the recommend usage. - Minor CI improvements
⚠️ IMPORTANT ⚠️
- Incorrect usage of
@ID(key: "...")
with any string other than"id"
will still trigger a fatal error at runtime as well as the deprecation warning. This is unavoidable without a source-breaking change, since the contents of the string can not be checked at compile time. - Incorrect usage of
@ID
where the type of the property is notUUID
- for example,@ID var id: Int?
- usually results in the extremely unhelpful compiler error "Type of expression is ambiguous without more context.
" Unfortunately, there doesn't seem to be a way to make this less opaque at the moment.
Remove limitations on nested relations in CompositeIDs
This patch was authored and released by @gwynne.
This update enables embedding @Composite[Optional]Parent
properties in a @CompositeID
, as well as:
- Removes some more
fatalError()
s and uses of force-unwrapping from Fluent - Improves suggestions in fatal errors from Parent/OptionalParent/Siblings
- More reliable behavior of
QueryBuilder.count()
when the queried model has a composite ID - Minor performance improvements in
Collection<Model>.delete(force:on:)
Additional relations support for CompositeID models
This patch was authored and released by @gwynne.
This update includes the following:
Model.joined(_:)
now works correctly with both aliased models and models with spaces.- Lots more documentation comments in various places.
DatabaseInput
got a new flag to allow explicitly requesting that all properties - not just modified ones - be included. See the inline documentation for more details. All built-in FluentKit property types appropriately respect this flag.- Fix completely incorrect implementation of
KeyPrefixingStrategy
's.camelCase
strategy, including adding unit tests. - Removed outdated checks for Swift version and OS minimums in Concurrency support since we require those minimums already.
@Group
properties with unset values no longer crash when encoded.@CompositeID
properties can now be encoded/decoded even when explicitly givennil
value.- Implemented
@CompositeOptionalParent
,@CompositeChildren
, and@CompositeOptionalChild
properties to go with@CompositeParent
, all of which allow fully describing relations even when the parent side of the relationship has a composite ID. - The minimum Swift version requirement has been bumped from 5.5 to 5.5.2. The recommended minimum version is 5.6.
Add ability to control migration log level
This patch was authored by @madsodgaard and released by @gwynne.
Adds a migrationLogLevel
configuration to control what log level to use for logging prepare & revert statements.
Complex join conditions and composite-key parent relations
This patch was authored and released by @gwynne.
This release includes significant feature additions, cleanups, and improvements:
- More complex conditions are now supported when using
.join()
in queries; the!=
operator is now supported, and conditions may be combined using&&
. - The new
@CompositeParent
property type may be used to reference a model which uses@CompositeID
as the parent of another model. ModelAlias
now works in most cases that were previously broken; among other cases, it is now possible to alias models which specify aspace
.- The poorly-considered "duplicate"
SQLList
type previously available inFluentSQL
is now deprecated; useSQLKit
's version instead. - Various code cleanups and minor performance improvements.
Fields
andModelAlias
now have detailed code documentation.- A new type,
SomeCodingKey
, is now available, providing a complete implementation ofCodingKey
for convenience in various cases when arbitrary string or integer keys are desired. - The SQL generated by FluentKit queries should now be slightly more consistent.
Fix support for composite ID models with QueryBuilder.count()
This patch was authored and released by @gwynne.
This functionality appeared to exist before but would actually crash at runtime. We now handle it correctly, including a test.
Allow use of create and delete for arrays of models that have composite IDs.
This patch was authored and released by @gwynne.
We no longer crash in a precondition failure when attempting to invoke Fluent's .create()
and .delete()
extensions to Collection
. This in particular enables the use of Siblings.attach(_:on:edit:)
with pivots which use a composite ID (most often consisting of the two parent relations).
Additional changes:
- Swift 5.4 support removed.
- NIO deprecation warnings fixed.
Revised error handling in Encodable conformance for Fields
This patch was authored and released by @gwynne.
This allows the fixes in vapor/postgres-kit#234 and vapor/mysql-kit#313 to work correctly and adds testing of the affected functionality.
Remove several sources of fatal errors from @Group
Performance and behavior improvements for encoding/decoding Fluent relations
This patch was authored and released by @gwynne.
This PR addresses the following items:
- The performance of eager loading for
@Parent
and@OptionalParent
relations should now scale more strictly linearly rather than exhibiting eventually quadratic behavior. This only affects the last step of eager loading, and will probably only be noticeable in queries which eager load a very large number of small models. - The information contained by a
FluentError.missingParent()
error is now more complete and consistent. - The default
Codable
conformance provided to any type conforming toFields
(which includes allModel
s) should now be slightly but noticeably more performant; a number of unnecessary extra intermediate steps and repeated actions have been removed. - Errors thrown from the default
Codable
conformance onFields
now retain the full coding path of the entire coding operation, rather than only the failing key. - Setting an
@OptionalParent
property'svalue
tonil
(or more precisely,.some(.none)
) no longer results in the property failing to encode itsid
.
There is a new protocol requirement on AnyCodableProperty
- while it is not expected that external users need to be concerned with said requirement, it does technically make this a semver-minor
update (see the comments on AnyCodableProperty.skipPropertyEncoding
for details of the new property).