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

Remove nanoseconds when touching updated at #415

Merged
merged 5 commits into from
Aug 15, 2019

Conversation

ruudk
Copy link
Contributor

@ruudk ruudk commented Jul 20, 2019

When you update a model, the updated_at field contains nanoseconds. But these nanoseconds are not stored in the database. So when you fetch the model again from the database does not contain the nanoseconds. This can lead to weird situations for clients.

For example, a iOS app sends a PUT request to update a certain model and stores the result. The updated_at field is 2019-07-20T10:36:19.819375Z. Later, when re-fetching the result from the API it returns a different response (because the updated_at field is now 2019-07-20T10:36:19Z). This leads to weird situations. Also, Swift doesn't understand the nanoseconds.

PS: I couldn't find a better way to remove the nanoseconds.

@ruudk ruudk requested a review from a team as a code owner July 20, 2019 10:59
@ruudk ruudk changed the base branch from master to development July 20, 2019 11:01
When you update a model, the `updated_at` field contains nanoseconds. But these nanoseconds are not stored in the database. So when you fetch the model again from the database does not contain the nanoseconds. This can lead to weird situations for clients.

For example, a iOS app sends a PUT request to update a certain model and stores the result. The `updated_at` field is `2019-07-20T10:36:19.819375Z`. Later, when re-fetching the result from the API it returns a different response (because the `updated_at` field is now `2019-07-20T10:36:19Z`). This leads to weird situations. Also, Swift doesn't understand the nanoseconds.
model.go Outdated Show resolved Hide resolved
model.go Outdated Show resolved Hide resolved
@stanislas-m stanislas-m merged commit 77a6d94 into gobuffalo:development Aug 15, 2019
@stanislas-m stanislas-m added this to the Next milestone Aug 15, 2019
@ruudk ruudk deleted the patch-1 branch August 15, 2019 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants