Swiftpack.co - Package - vapor/fluent-kit


Stars: 34

Used By

Total: 0


Require SQLKit 3.1.0 - 2020-06-02 19:51:08

This patch was authored and released by @tanner0101.

The previous tag used new API added in SQLKit 3.1.0. This release bumps the version requirement for that package to prevent build errors if swift package update is not run.

Add helper methods for adding multiple Migrations at once - 2020-05-30 14:46:05

This patch was authored and released by @gwynne.
  • Adds an overload of Migrations.add(_:to:) which accepts an array of Migration, e.g.:

    app.migrations.add([ConfigModel.Migration(), SolarSystem.Migration()])
    app.migrations.add([UserModel.Migration(), PostModel.Migration()], to: .psql)

    As a new public API, this requires a semver-minor release.

  • Also adds an overload which accepts a variadic parameter of Migration type:

    app.migrations.add(ConfigModel.Migration(), SolarSystem.Migration())
    app.migrations.add(UserModel.Migration(), PostModel.Migration(), to: .psql)
  • Adds a benchmark test for the new methods, just for the heck of it.

FluentKit 1.0.0 GM - 2020-05-29 21:30:05

This patch was authored and released by @tanner0101.

Given the large number of fixes currently on the gm branch, I've decided to release them as a final rc version now. The official 1.0.0 will release will come as soon as the docs for Fluent are finished.

Unify field key path semantics (#268).

Makes FieldKey path usage consistent across all db driver types. SQL no longer treats field key paths differently than NoSQL. This means @Group now always serializes as a flat structure. Support for nested structures and dynamic structuring behavior between NoSQL and SQL will be added in the future with a more reliable design.

Improve property protocols (#268).

FieldProtocol and PropertyProtocol have been cleaned up and split into more descriptive protocols:

  • AnyProperty
  • AnyDatabaseProperty
  • AnyCodableProperty
  • AnyQueryableProperty
  • Property
  • QueryableProperty

Add Database.inTransaction (fixes #23, #119).

Database drivers are expected to keep track of whether they are already in a transaction and not start a new one if they do not supported nested transactions. Users can check if the database they are using is currently in a transaction using the inTransaction flag.

Fix issues filtering and setting @OptionalField when nil (#270).

@OptionalField.value is now a double optional again. This was previously changed to avoid double optionals which can be tricky to work with, but a single optional does not accurately convey all states an @OptionalField can be in:

  • nil: Uninitialized
  • .some(nil): Initialized to nil.
  • .some(.some): Initialized to a value.

Furthermore, @OptionalField's associated value type being an optional is required for generic operators (like ==) and methods (like set(_:to:) to properly accept nil values.

Add batch delete method on collection of models (#270, fixes #114).

A new method delete(force:on:) is now available on collections of models.

let earth: Planet = ...
let mars: Planet = ...
[earth, mars].delete(on: db)

Schema update constraints (#270, fixes #235).

Schema constraints can now be created and deleted during SchemaBuilder.update().

    .unique(on: "name")

Add constraint names (#270, fixes #118).

New methods on SchemaBuilder are now available for naming unique and foreign key constraints.

    .field("name", .string, .required)
    .unique(on: "name", name: "name_index")

Constraints can now be deleted by name as well.

    .deleteConstraint(name: "name_index")

Arbitrary join(_:on:) ordering (#270, fixes #128).

QueryBuilder.join's on parameter can now have fields appear on either side of ==.

School.query(on: self.database)
    .join(City.self, on: \School.$city.$id == \City.$id)
    // or 
    .join(City.self, on: \City.$id == \School.$city.$id)

Add EnumBuilder.read() (#270, fixes #194).

EnumBuilder now supports reading the enum metadata outside of create(). This is useful for re-using enums between schemas.

database.enum("planet_type").read().flatMap { planetType in
        .field("type", planetType)

Improve readability of Codable errors (#270, fixes #231).

DecodingErrors thrown by Model now include key path information.

Several small bug and convenience API fixes (#270).

Track Migrations Per Database - 2020-05-18 17:03:08

This patch was authored and released by @calebkleveter.

Migrations are now tracked on the database they are run on, instead of all migrations being tracked on the default database. This resolves bugs that could occur when running the same migration on multiple databases.

Fix setting nil on @OptionalField - 2020-05-06 18:54:48

This patch was authored and released by @tanner0101.

Fixes an issue where setting an @OptionalField to nil would not save to the database (#267).

Fixes timestamp update when model doesn't have changes - 2020-05-01 14:43:19

This patch was authored by @123FLO321 and released by @tanner0101.
  • Fixes updated timestamp being updated when model doesn't have changes (#263).
  • Adds tests for model.hasChanges (#263).
  • Adds tests to test updates without changes on models with @Timestamp (#263).

Publicize NestedProperty and DatabaseOutput utilities - 2020-05-01 14:41:07

This patch was authored by @123FLO321 and released by @tanner0101.
  • Makes NestedProperty Initializer public (#262).
  • Makes DatabaseOutput cascading and nested functions public (#262).

Fix inverse subset serialization - 2020-04-24 15:04:42

This patch was authored by @mcdappdev and released by @tanner0101.

Adds a fix for subset serialization when the RHS is empty (#258, fixes #257).

Add discardableResult to QueryBuilder.group - 2020-04-22 22:34:53

This patch was authored and released by @mcdappdev.

Removes a warning when nesting multiple query.group(relation:) calls

Query Builder Soft Delete - 2020-04-21 18:17:52

Adds a new force parameter to QueryBuilder delete calls:

MyModel.query(on: db).filter(\.$name == "Vapor").delete(force: true)

⚠️ The default behavior of delete on QueryBuilder has changed. If the model is soft deletable the query builder will now honor this instead of force deleting.

Made DatabaseSchema.DataType.Enum Initializer Public - 2020-04-14 20:08:54

This patch was authored and released by @calebkleveter.

Adds a public initializer to the DatabaseSchema.DataType.Enum type.

Test Database Improvements - 2020-04-09 17:57:41

This patch was authored and released by @tanner0101.

Adds new TestDatabase helpers (#241).

Revert "Encode @OptionalParent to nil if id is nil" - 2020-04-09 17:32:49

This patch was authored and released by @tanner0101.

Reverts vapor/fluent-kit#236 (#240). This change was inadvertently breaking.

Make @Timestamp properties stable again - 2020-04-08 12:52:51

This patch was authored by @gwynne and released by @calebkleveter.
  • Fixes a bug which caused @Timestamp properties to have their values specified as inputs to every INSERT and UPDATE query issued for any model containing them, regardless of whether the query was supposed to update them. (For example, an UPDATE query really should not be specifying createdAt unless it was explicitly overwritten by the user.)

  • As part of the test verifying the fix, a new built-in iso8601WithMilliseconds timestamp format is now available. This is iso8601 with the addition of exactly three digits of sub-second precision.

Encode @OptionalParent to nil if its ID is nil - 2020-04-06 13:08:20

This patch was authored by @123FLO321 and released by @calebkleveter.

If the ID value for the parent in an @OptionalParent property is nil, then we encode the property nil instead of { id: nil }.

Format Deleted Timestamp For Soft Delete Exclusion - 2020-04-02 22:35:30

This patch was authored and released by @calebkleveter.

Fixes model exclusion when querying soft deletable models that use formatted timestamps.

Make @Timestamp encode as Date - 2020-04-02 16:07:06

This patch was authored by @tanner0101 and released by @calebkleveter.

Reverts a change in https://github.com/vapor/fluent-kit/pull/221 causing @Timestamp to serialize it's format to Codable. @Timestamp will now always yield a Date to Codable allowing the coder to determine its formatting (#228).

Custom Timestamp Formats - 2020-03-31 21:00:53

This patch was authored and released by @calebkleveter.

Adds a format parameter to the Timestamp property wrapper, allowing you to pass in a custom formatter that will be used to convert the stored Date to a codable type before it is store in the database. By default, the date will still be converted to the database-specific date type.

@Timestamp(key: "created_at", on: .create, format: .iso8601)

Add an @OptionalEnum property wrapper - 2020-03-24 21:52:00

This patch was authored by @gwynne and released by @tanner0101.

This is to @Enum what @OptionalParent is to @Parent and @OptionalField is to @Field.

Provide custom value operator handling for enum - 2020-03-19 15:45:41

This patch was authored by @mattpolzin and released by @tanner0101.

Treat enum query filters differently than other types because they cannot be bound.

Fixes https://github.com/vapor/fluent-kit/issues/202.

Add ability to specify `IF NOT EXISTS` for schema create actions - 2020-03-17 13:51:16

This patch was authored and released by @gwynne.
  • Takes the form of a new API on SchemaBuilder and additional flag on DatabaseSchema. The behavior is 100% backwards compatible.
  • Specifying this flag has no effect on .update or .delete schema actions.
  • This flag has no effect on the MongoDB driver.
  • MigrationLog now both uses this flag and issues its create action unconditionally instead of gating it behind a spurious query; as a result, it no longer issues an error message whenever migrations are run on an empty database (which may happen often in comprehensive unit tests). This should not be a breaking change for anyone.
  • If MigrationLog's schema ever needs to change in the future, the use of this flag will require additional code be added to support that requirement. Hopefully the schema should not change short of a semver-major upgrade.

Handle SQL Bind Values in EnumProperty - 2020-03-12 22:29:23

This patch was authored and released by @calebkleveter.

When you decode a Fields type from a database row that has an Enum property, because the Enum.decode(from:) method simply calls its internal field.decode(from:) method, the field.inputValue property ends up having a .bind case with a perfectly valid case name as it's associated value. This release adds handling to the EnumProperty.value property for the .bind case.

Fix @Enum codable serialization - 2020-03-06 23:15:19

This patch was authored by @jccampagne and released by @tanner0101.

Fixes an error when encoding @Enum fields using Codable (#198).

Batch update timestamps at the same time - 2020-03-06 21:38:29

This patch was authored and released by @tanner0101.

Updates the batch model creation method to set timestamps to the same value (#197, #125).

Omit empty filter groups from query - 2020-03-06 21:10:19

This patch was authored and released by @tanner0101.

QueryBuilder filter groups that have no filters are now omitted from the query (#195, fixes #9).

Pass join method parameter - 2020-03-06 16:47:54

This patch was authored by @varungakhar and released by @tanner0101.

Correctly passes join method parameter through to underlying methods (#193).

Add XCTFluent module with TestDatabase - 2020-03-06 16:10:15

This patch was authored by @mattpolzin and released by @tanner0101.

Adds new XCTFluent module for testing. This includes a TestDatabase helper that lets you mock the row results for each query (#110).

let db = TestDatabase()
db.append(queryResult: [])
db.append(queryResult: [
    TestOutput(["id": ..., "name": "Earth"])

try Planet.query(on: db).all().wait() // []
try Planet.query(on: db).all().wait() // [Planet(id: ..., name: "Earth")]

Improve invalid @Field access fatalError - 2020-03-05 20:38:26

This patch was authored by @grosch and released by @tanner0101.

Improves error messages when invalid access to @Field causes a fatalError (#182).

Siblings detach array support - 2020-03-04 19:39:50

Add array support to @Siblings.detach(_:on:) (#191, fixes #179).

earth.$tags.detach([smallRocky, inhabited], on: db)

This patch was authored and released by @tanner0101.

Make MigrationLog's name unique - 2020-03-04 18:15:48

Adds a unique constraint to the MigrationLog schema (#190, fixes #189).

For existing databases, use SQL similar to the following to add this constraint manually.

ALTER TABLE "_fluent_migrations" CONSTRAINT "uq:_fluent_migrations.name" UNIQUE ("name")

This patch was authored and released by @tanner0101.