Closed co60ca closed 1 year ago
This sounds like a pretty reasonable change. It’s possible it might break something, but a panic isn’t something that would be checked against super frequently so I see it as a pretty low risk change.
@JessieAMorris please consider my PR and thank you.
Proposal
https://github.com/DATA-DOG/go-sqlmock/blob/b2f0b45ee89df7dfd29e32a5f9bf087791c9a61f/rows.go#L169 This panic can be confusing, its simple enough to debug if you know what you're doing but if you pass a string with
len() = 25
it will of course panic if the developer does not spreading. Like with:rows.AddRow(v)
vsrows.AddRow(v...)
(Spreading will cause another issue with[]string
but I digress.The former will compile but will panic. I wonder if you'd accept it to say
"Expected number of values to match number of columns, expected %d, actual %d"
to at least hint.I wonder if this is acceptable or if it would break backwards compatibility in an unacceptable way. If you'd accept this change I'd gladly provide a PR.
Use-cases
Changing the panic message should simplify debugging sqlmock during development.
Otherwise we can close.