Skip to content

Releases: vapor/fluent-kit

Enforce correct @ID(key:) usage at compile time

04 Mar 02:04
dd6b7f8
Compare
Choose a tag to compare
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 ⚠️

  1. 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.
  2. Incorrect usage of @ID where the type of the property is not UUID - 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

26 Feb 14:14
636a59e
Compare
Choose a tag to compare
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

19 Feb 14:30
cc8fed9
Compare
Choose a tag to compare
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 given nil 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

12 Feb 11:50
10f3213
Compare
Choose a tag to compare
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

07 Feb 11:22
d03b0ff
Compare
Choose a tag to compare
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 a space.
  • The poorly-considered "duplicate" SQLList type previously available in FluentSQL is now deprecated; use SQLKit's version instead.
  • Various code cleanups and minor performance improvements.
  • Fields and ModelAlias now have detailed code documentation.
  • A new type, SomeCodingKey, is now available, providing a complete implementation of CodingKey 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()

04 Nov 08:52
be7912e
Compare
Choose a tag to compare
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.

04 Nov 08:04
9c79880
Compare
Choose a tag to compare
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

28 Oct 17:06
33d498d
Compare
Choose a tag to compare
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

16 Aug 01:43
38670d2
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.

This removes most of the easier ways to cause fatal errors (esp. from user input) from @Group's implementation.

Fixes #530

Performance and behavior improvements for encoding/decoding Fluent relations

11 Aug 02:30
7fc64d3
Compare
Choose a tag to compare
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 to Fields (which includes all Models) 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 on Fields now retain the full coding path of the entire coding operation, rather than only the failing key.
  • Setting an @OptionalParent property's value to nil (or more precisely, .some(.none)) no longer results in the property failing to encode its id.

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).