-
Notifications
You must be signed in to change notification settings - Fork 46
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
fix: csv output handles time and interface values #351
Conversation
storage/csv.go
Outdated
// Special formatting for known types | ||
if ft.PkgPath() == "time" && ft.Name() == "Time" { | ||
v := fv.Interface().(time.Time) | ||
row[i] = v.Format("2006-01-02T15:04:05.999Z07:00") |
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.
row[i] = v.Format("2006-01-02T15:04:05.999Z07:00") | |
row[i] = v.Format(PostgresTimestampFormat) |
@@ -169,10 +173,29 @@ func (c *CSVBatch) PersistModel(ctx context.Context, m interface{}) error { | |||
for i, f := range t.fields { | |||
fv := value.FieldByName(f) | |||
fk := fv.Kind() | |||
if (fk == reflect.Slice || fk == reflect.Map || fk == reflect.Ptr || fk == reflect.Chan || fk == reflect.Func) && fv.IsNil() { | |||
if (fk == reflect.Slice || fk == reflect.Map || fk == reflect.Ptr || fk == reflect.Chan || fk == reflect.Func || fk == reflect.Interface) && fv.IsNil() { |
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.
nit: Worth breaking these into seaparate lines?
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 don't think it would add much to readability. Besides, we all have screen resolutions beyons 640x480 😀
require.NoError(t, err) | ||
assert.EqualValues(t, | ||
"height,value\n"+ | ||
"42,\"[{\"\"Source\"\":\"\"some task\"\",\"\"Error\"\":{}}]\"\n", |
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.
This assertion does not match the Error contained in tm
.
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.
Will look into that
No description provided.