-
-
Notifications
You must be signed in to change notification settings - Fork 117
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Wrap filters in groups in SQLQueryConverter * Made test Galexy model soft-deletable * Store 2 models in FluentBenchmarker.testUpdate test case * Import Foundation.Date to Galaxy.swift file * Added 'deleted_at' field to GalaxyMigration database schema * Fix expected count of keys in FluentBenchmarker.testParentSerialization test case * Remove top-level parentheses from SQL query filters * Revert changes to Galaxy test model and FluentBenchmarker.testUpdate test case * Use Trash model to test soft-delete model behaviour * Temporarily remove filter grouping to ensure tests fail * Use equality operator instead of prefix check in FluentBenchmark.testUpdate * Revert all changes in SQLQueryConverter.filters(_:) method * Ensure all contents of Trash instances are the same before update in FluentBecnhmarker.testUpdate test case * Changed Trash.id property type to UUID * Call .create and .update for FluentBenchmarker.testUpdate Trash models instead of .save * Defined Trash.id as non-auto in TrashMigration * Create new Trach model to run update * Require Trash 'id' values to be unique * Set .deletedAt properties for Trash models in FluentBenchmark.testUpdate * Group nested predicate groups for SQL queries * Use 'UNIQUE' custom constraint on 'id' field in TrashMigration * Don't set 'deleted_at' field when updating Trash model in FluentBenchmark.testUpdate test case * fix tests * rm extra changes
- Loading branch information
1 parent
5df66ee
commit 0c623e7
Showing
3 changed files
with
79 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import Foundation | ||
import FluentKit | ||
|
||
final class Trash: Model { | ||
static let schema = "trash" | ||
|
||
@ID(key: "id") | ||
var id: UUID? | ||
|
||
@Field(key: "contents") | ||
var contents: String | ||
|
||
@Timestamp(key: "deleted_at", on: .delete) | ||
var deletedAt: Date? | ||
|
||
init() { } | ||
|
||
init(id: UUID? = nil, contents: String, deletedAt: Date? = nil) { | ||
if let id = id { | ||
self.id = id | ||
self._id.exists = true | ||
} | ||
self.contents = contents | ||
self.deletedAt = deletedAt | ||
} | ||
} | ||
|
||
struct TrashMigration: Migration { | ||
func prepare(on database: Database) -> EventLoopFuture<Void> { | ||
return database.schema(Trash.schema) | ||
.field("id", .uuid, .identifier(auto: false), .custom("UNIQUE")) | ||
.field("contents", .string, .required) | ||
.field("deleted_at", .datetime) | ||
.create() | ||
} | ||
|
||
func revert(on database: Database) -> EventLoopFuture<Void> { | ||
return database.schema(Trash.schema).delete() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters