Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FluentKit 1.0.0 GM #270

Merged
merged 50 commits into from
May 29, 2020
Merged

FluentKit 1.0.0 GM #270

merged 50 commits into from
May 29, 2020

Conversation

tanner0101
Copy link
Member

@tanner0101 tanner0101 commented May 7, 2020

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

database.schema("planets")
    .unique(on: "name")
    .update()

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

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

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

Constraints can now be deleted by name as well.

database.schema("planets")
    .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
    database.schema("planets")
        .field("type", planetType)
        .create()
}

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

* unify field path structure for all drivers

* cleanup files

* rm dead code

* nested group option

* protocol cleanup + timestamp updates

* updates
@tanner0101 tanner0101 marked this pull request as draft May 7, 2020 19:47
@tanner0101 tanner0101 added the enhancement New feature or request label May 7, 2020
@tanner0101 tanner0101 added this to Awaiting Review in Vapor 4 via automation May 7, 2020
tanner0101 and others added 2 commits May 12, 2020 10:11
* Add tests for placeholder for dummy database

* Fix placeholder position

Placeholder position should start at 1, not 2.
No need to add 1 to position.

* Rename variable to result
@tanner0101 tanner0101 mentioned this pull request May 12, 2020
@tanner0101 tanner0101 marked this pull request as ready for review May 29, 2020 17:59
@tanner0101 tanner0101 added the semver-major Breaking changes label May 29, 2020
@tanner0101 tanner0101 merged commit 9e2f782 into master May 29, 2020
Vapor 4 automation moved this from Awaiting Review to Done May 29, 2020
@tanner0101 tanner0101 deleted the gm branch May 29, 2020 21:30
@tanner0101
Copy link
Member Author

These changes are now available in 1.0.0-rc.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment