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

record timestamp if model has updatedAt key #566

Merged
merged 6 commits into from
Oct 10, 2018

Conversation

rausnitz
Copy link
Sponsor Contributor

re: issue #565

@rausnitz
Copy link
Sponsor Contributor Author

Still waiting for this to be merged so I added a workaround here: #565.

Copy link
Member

@tanner0101 tanner0101 left a 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)
Copy link
Member

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

Copy link
Sponsor Contributor Author

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.

@tanner0101 tanner0101 added this to the 3.0.1 milestone Oct 10, 2018
Copy link
Member

@tanner0101 tanner0101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, thanks!

@tanner0101 tanner0101 merged commit 413a975 into vapor:master Oct 10, 2018
@penny-coin
Copy link

Hey @rausnitz, you just merged a pull request, have a coin!

You now have 1 coins.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants