DATA-DOG / go-sqlmock

Sql mock driver for golang to test database interactions
Other
5.95k stars 404 forks source link

fixes csv parse errors being silently ignored #315

Closed IvoGoman closed 1 year ago

IvoGoman commented 1 year ago

Before this change the FromCSVString would return a subset of rows in case csvReader.Read() returns an error but ignore the error itself. E.g.

one, two, three
one, two, "error""

The second line will result in a ErrQuote but the error is not handled. Instead the first row and no error are returned. This will then lead to undesired behavior of tests relying on this data.

The method FromCSVString already runs into a panic if the number of columns do not match. Therefore, I propose that an invalid input should run into a panic as well.

All errors returned bycsvreader.Read, besides from io.EOF, should lead to a panic, as they indicate the csv string could not properly be parsed.

IvoGoman commented 1 year ago

@fatelei could you take a look?

fatelei commented 1 year ago

@fatelei could you take a look?

ok