-
Notifications
You must be signed in to change notification settings - Fork 101
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
feat: Change timestamp field in transactions #269
feat: Change timestamp field in transactions #269
Conversation
275fe33
to
c97f440
Compare
Codecov Report
@@ Coverage Diff @@
## main #269 +/- ##
==========================================
- Coverage 71.85% 71.48% -0.37%
==========================================
Files 82 79 -3
Lines 4302 4230 -72
==========================================
- Hits 3091 3024 -67
- Misses 936 939 +3
+ Partials 275 267 -8
Continue to review full report at Codecov.
|
280a017
to
5a82b7c
Compare
@@ -91,7 +91,6 @@ func (s *Store) AppendLog(ctx context.Context, logs ...core.Log) error { | |||
func (s *Store) lastLog(ctx context.Context, exec executor) (*core.Log, error) { | |||
var ( | |||
l core.Log | |||
ts sql.NullString |
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.
why is this removed ? shouldnt it have been replaced by a NullTime ?
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.
The Scan() method is called directly with a pointer on the date :
err := rows.Scan(&l.ID, &l.Type, &l.Hash, &l.Date, &data)
No need to handle NULL values as the date is required.
c0fa3c2
to
b37c281
Compare
730a458
to
c301dfa
Compare
0e29950
to
54172b9
Compare
Add MarshalJSON() on transaction object to encode time.Time as rfc3339 (for backward compatibility). Also, since the dates was previously stored as rfc3339 into the database, we round to the second the generated dates when creating new logs.
54172b9
to
bc4438c
Compare
Change timestamp field in transactions from string to time.Time
This change the type of the field 'Timestamp' inside transactions.
Both sqlite and Postgres can handle encoding of the field without additional efforts.
But, at least sqlite, if the db column is not defined as a date type, is not able to decode the value directly to a time.Time struct.
So the decoding is still manual for reading transactions (ok on logs since the column has a date type).
Both SQLite and Postgres encode time.Time as rfc3339nano.
So, to keep backward compatibility, we :
We could change the precision in a later release.
Also the PR set the same date for the log, and the generated transactions.
It was not the case previously. I don't think it is a breaking change since the logs is not exposed anywhere actually.
The PR also remove verbose logging on tests because the tests give so many line and the CI refuse to display all the lines.
Type of change
What parts of the code are impacted ?
Checklist: