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

fix: csv output handles time and interface values #351

Merged
merged 2 commits into from
Jan 19, 2021
Merged

Conversation

iand
Copy link
Contributor

@iand iand commented Jan 13, 2021

No description provided.

@iand iand requested a review from frrist January 13, 2021 12:36
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")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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() {
Copy link
Contributor

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?

Copy link
Contributor Author

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",
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will look into that

@iand iand merged commit 52e5a9c into master Jan 19, 2021
@iand iand deleted the iand/csv-times branch January 19, 2021 11:22
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