-
-
Notifications
You must be signed in to change notification settings - Fork 174
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
record timestamp if model has updatedAt key #566
Conversation
Still waiting for this to be merged so I added a workaround here: #565. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this bug fix! This just needs a test case to ensure the new code works and that we don't have a regression in the future.
@@ -52,6 +52,9 @@ extension QueryBuilder where Result: Model, Result.Database == Database { | |||
public func update<T>(_ field: KeyPath<Result, T>, to value: T) -> Self where T: Encodable { | |||
Database.queryActionApply(Database.queryActionUpdate, to: &query) | |||
Database.queryDataSet(Database.queryField(.keyPath(field)), to: value, on: &query) | |||
if Result.updatedAtKey != nil { | |||
Database.queryDataSet(Database.queryField(.keyPath(\Result.fluentUpdatedAt)), to: Date(), on: &query) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think .keyPath(\Result.fluentUpdatedAt)
should be .keyPath(Result.updatedAtKey)
(using if let
to unwrap the optional).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good! I'll submit a test soon. I just realized FluentBenchmark
exists and I see now how tests are being done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks!
Hey @rausnitz, you just merged a pull request, have a coin! You now have 1 coins. |
re: issue #565