Skip to content

Releases: vapor/fluent-kit

1.43.0 - Leverage the new support for nested path expressions in SQLKit

11 Jul 07:17
763627f
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.

Fluent now takes generic advantage of the new support added by vapor/sql-kit#169 when generating nested subpath expressions.

(Unfortunately, Fluent has never actually invoked this code path to begin with, except via an explicit call to .sql(json:_:), so it doesn't change much at the moment. However, this would always have been a prerequisite to make the real support for it in Fluent's API actually work, so it's a step in the right direction.)

SQLJSONColumnPath is now deprecated in favor of using SQLKit's new SQLNestedSubpathExpression. #572

Explicitly log migration errors

09 Jun 15:25
2d7dce5
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.

This ensures errors thrown during migration (both prepare and revert) are fully logged regardless of the behavior of calling code.

Enable using the attached model during pivot editing

03 Jun 09:06
04691f8
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.

When using Siblings.attach(_:on:_:) with an editing closure, this code would historically crash with a fatal error:

planet.$tags.attach([tag1, tag2], on: database) { pivot in
    print(pivot.tag.name)
    // fatal error: Parent relation not eager loaded, use $ prefix to access: Parent<PlanetTag, Tag>(key: "tag_id")
}

The attach() methods now provide the "right-hand" side of the relation (e.g. left.$siblings.attach([right1, right2])) on the pivot model passed to the editing closure.

Unfortunately, due to limitations of Fluent's design and of property wrappers, it is not possible to also provide the "left-hand" side of the relation, but this is usually less of a concern. The expected use case for having the right-hand model available is to be able to get data from the right-hand model for setting properties of the pivot when attaching an array of siblings in one call. Without this change, this was only possible by matching the right-hand model's ID with one from the original input array. (This being said, this change affects the single-model version of attach() as well, since there is no drawback to doing so.)

This is a solely additive change; it has no effect whatsoever on what data goes into the database, and does not incur any additional speed or memory overhead.

Generate deterministic column ordering in insert and update queries

02 May 16:32
e53acf9
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.

This is an updated version of #556 by @rausnitz which updates the generation of INSERT queries to be both deterministic and more performant by eliding pointless repetition of the Fluent -> SQL conversion of the field list.

Additional kudos for @rausnitz for his enthusiasm, which inspired me to take another hard look at the existing logic!

Closes #543

Improved migration performance, better error reporting, and other cleanups

02 May 16:23
0fdeff6
Compare
Choose a tag to compare
This patch was authored and released by @gwynne.
  • FluentError is now CustomDebugStringConvertible
  • Fixes #542 by conditionally conforming LoggingOverrideDatabase to SQLDatabase
  • Migration no longer spends time checking for prerelease migration names or allocating excess futures
  • The Mirror bypass is now enabled for Swift 5.9
  • Fluent benchmark suite now has much better error handling
  • Fluent benchmarks now run ~5-10% faster (up to 15% for SQL databases)

Update min Swift version to 5.6 and make platform versions consistent

14 Apr 01:01
559dc9c
Compare
Choose a tag to compare

Allow eager-loading of deleted models

23 Mar 11:31
21d99b0
Compare
Choose a tag to compare
This patch was authored by @tarag and released by @gwynne.

Allows eager-loading of soft-deleted models. For maximum flexibility, choosing whether to load soft-deleted models or not is performed for each relation at each query call.

Usage is as follows: let galaxies = try Galaxy.query(on: self.database).with(\.$stars, withDeleted: true)

Use of default argument value of false requires no change to existing code to keep existing behaviour.

Fixes #375.

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.