go-sqlmock icon indicating copy to clipboard operation
go-sqlmock copied to clipboard

fix issue 209: add output parameters support

Open riccardos77 opened this issue 1 year ago • 1 comments
trafficstars

this PR address the lack of support for output parameters adding:

  • sqlmock.NamedOutputArg and sqlmock.NamedInputOutputArg functions that support mapping values for sql.Named output and input/output parameters
  • sqlmock.TypedOutputArg function that support mapping values for unnamed output parameters, matching by type. This is required to mock for example go-mssqldb's ReturnStatus (https://github.com/microsoft/go-mssqldb/blob/main/mssql.go). To work, the output type doesn't need to be changed, so to avoid breaking changes, I've added a PassthroughValueConverter that allows the specified types to bypass the default ValueConverter. If there is a better solution, I will be happy to improve it.

Examples have been added in examples/output folder.

This PR should completely fix issue #209.

riccardos77 avatar Apr 06 '24 21:04 riccardos77