Closed chengguangyu closed 4 years ago
the only option is to use custom converters, which can be provided as an sqlmock option. but that will be messy, unless the db driver you use exports them
is now supported with custom converter, see the pull request above
Hello,
I've been using a lot of go-sqlmock. However, I didn't find a way to mock the returned type from rows.Scan() when called database.Query (a rows object).
I have already successfully inplement the ConvertValue() func for my own custom type
type StringSliceType []string
which will makemock.NewRows([]string{"myarray"}).AddRow(StringSliceType {"hello", "world"}).
enabled. I can input custom type to mock the Query result.My 3rd party library (https://github.com/kshvakov/clickhouse) supports []string as supported data types so I can write:
However, there will be a type mismatch.
How could I extend go-sqlmock to allow mocking custom data types with the Scan function?
Thank you very much.