Skip to content

Releases: vapor/fluent-kit

SQLKit Updates

22 Jan 03:33
b9fb46e
Compare
Choose a tag to compare
SQLKit Updates Pre-release
Pre-release

Adds support for SQLAlterTable.dropColumns.

Fix ID.Generator.random Overwrite

21 Jan 18:46
e709458
Compare
Choose a tag to compare
Pre-release

ID.Generator.random no longer overwrites user-supplied identifiers. Fixes #132.

@ID(key: "id", generatedBy: .random)
var id: UUID?

.random is the default for UUID.

Pagination and Range

16 Jan 22:50
7dc374e
Compare
Choose a tag to compare
Pagination and Range Pre-release
Pre-release

Adds paginate method to QueryBuilder which returns a Page of models. Page includes the array of models and a PageMetadata struct including information on current page, items per page, and total number of items.

Fluent adds a paginate(for:Request) method that automatically decodes the PageRequest from the Request's query string.

struct TodoController {
    func index(req: Request) throws -> EventLoopFuture<Page<Todo>> {
        Todo.query(on: req.db).paginate(for: req)
    }
}

Page can also map its items to different types.

let todos = Todo.query(on: req.db).paginate(for: req).map { page in
    page.map(Todo.Public.init)
}
print(todos) // ELFuture<Page<Todo.Public>>

In addition to pagination, QueryBuilder now supports range methods accepting Swift's Range literals.

query.range(2..<5) // returns at most 3 results, offset by 2
query.range(..<5) // returns at most 5 results

Added Model.hasChanges Property

16 Jan 18:05
d3bb891
Compare
Choose a tag to compare
Pre-release

Adds a .hasChanges computed property to the Model protocol, which can be used to check if there are any fields that have had their values set, but the model has not yet been saved to the database.

Add UInt8-backed enum test

26 Dec 17:13
877bf49
Compare
Choose a tag to compare
Pre-release

Adds a test to ensure models with UInt8-backed enum properties work properly.

Don't eager load on empty result set

26 Dec 16:33
27d8b35
Compare
Choose a tag to compare
Pre-release

Fluent's QueryBuilder no longer attempts to run eager loads if all() returns zero models. This fixes an issue where attempting to eager load children on a query that returned zero models would result in a syntax error (#117).

Duplicate constraint name fix

17 Dec 04:42
c232981
Compare
Choose a tag to compare
Pre-release
  • Constraint names (unique and foreign key) now include the table name (#112, #113)

  • Publicized Model.key(for:) method for getting field key strings statically (#113)

FluentKit 1.0.0 Beta 2.4

13 Dec 23:51
5a2fbd6
Compare
Choose a tag to compare
Pre-release
  • Fix array test to store json array as .array(of: .json) (#111)

FluentKit 1.0.0 Beta 2.3

11 Dec 04:02
2535037
Compare
Choose a tag to compare
Pre-release
  • Standardized eagerLoaded value on all relations. (#106, #109)

FluentKit 1.0.0 Beta 2.2

11 Dec 01:27
e77647e
Compare
Choose a tag to compare
Pre-release
  • Adds array(of:) case to DatabaseSchema.DataType (#105)
  • Adds test for model containing array fields (#105)
  • Adds a performance test to FluentBenchmarker (#105)