Do not change created at during update #625
Conversation
| Fields: Fields{}, | ||
| } | ||
| res.Version = res.Version + 1 | ||
| res.Type = wi.Type |
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 we do not need this Type assignment. (Can be skipped). Because we are not allowing type change yet.
Also, Fields are not reset. IMO we need to reset ?
While update API, we replace whole set of Fields with new input Fields but looking at this change we will be keeping old values in Fields.
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.
As of now, we are allowing the type change, but there is a discussion in UX to not allow. Until that is getting clarified let it be there.
Will reset Fields.
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.
Fields reset in 43af7d2
| log.Printf("updated item to %v\n", newWi) | ||
| return convertWorkItemModelToApp(wiType, &newWi) | ||
| log.Printf("updated item to %v\n", res) | ||
| return convertWorkItemModelToApp(wiType, &res) | ||
| } |
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.
Can we have a small test that will expose this issue and check if created_at is same as before after Update calls.
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.
Fixed. Ref. 43af7d2
Current coverage is 69.90% (diff: 100%)@@ master #625 diff @@
==========================================
Files 74 74
Lines 4264 4300 +36
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
+ Hits 2971 3006 +35
Misses 1009 1009
- Partials 284 285 +1
|
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.
Old code updates created_at after update API call (unwanted update)
created_at | updated_at
------------------------+-------------------------------
0001-01-01 00:00:00+00 | 2016-12-26 06:22:19.714545+00
(1 row)
This PR prevents that
When item was created ->
postgres=# select created_at,updated_at from work_items where id = 5;
created_at | updated_at
-------------------------------+-------------------------------
2016-12-26 06:23:21.265841+00 | 2016-12-26 06:23:21.265841+00
(1 row)
When item was updated ->
postgres=# select created_at,updated_at from work_items where id = 5;
created_at | updated_at
-------------------------------+-------------------------------
2016-12-26 06:23:21.265841+00 | 2016-12-26 06:24:07.158964+00
(1 row)
fixes #623