-
-
Notifications
You must be signed in to change notification settings - Fork 402
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
Rows does not implement database/sql/driver.Rows #76
Comments
Yes indeed, need to mention that. did not made any sense to keep the driver.Rows compatibility since it is not needed when mocking rows to return from driver. and though, changing from sqlmock.Rows interface to struct could also lead in some backward incompatible changes if interface was used in helper functions using the reference. There had to be changes though, due to 1.8 support of multi result sets. Hope it did not cause much of the trouble? Will add notes in readme and the pull request referenced, cheers. |
It did cause a little bit of heartburn for us; it was tedious to adjust, but not difficult. Is there any chance the exported |
well, I cannot change this back, since the release was already made and that would make again - backward incompatible change. though could have tagged it with 2.0.0 instead, but haven't thought that many users would refer to sqlmock.Rows by type somewhere in tests. anyway, a mistake was done and users have already adapted their code. I've made the release tag description with notification, hope to avoid such mistakes in the future, guess there won't be so many changes to the sql.driver next times. |
Thank you for the quick response and for updating the release description. I propose that the calculus is one of whether the bulk of users has upgraded to the most recent release. If most have upgraded and they had to change a reference to Our use case for referencing |
I will not revert, because people have already upgraded and resolved these changes, I will not inflict that change again (that is the worst thing I can do now). Just migrate to the pointer. |
Hey, I don't expect a change here but I wanted to chime in just to document another pain point associated with the removal of the My specific use case is in mocking out the parameter to I've been unable to find a way to adapt things to fit, so I'm having to give up on testing the function in question directly and instead factor out its guts and test those, leaving a thin layer of logic without test coverage. Or is there a way around this that I'm missing? |
Hi @snargleplax sqlmock supports sql driver interface. I do not understand how you use Rows? Because when you mock query to return rows it will always return the Rows interface: mock.ExpectQuery("SELECT (.+) FROM articles WHERE id = ?").
WithArgs(5).
WillReturnRows(rs)
rows, err := db.Query("SELECT (.+) FROM articles WHERE id = ?", 5) In this example |
Hi @l3pp4rd, thanks for the response. My use case is a bit different than what you illustrate; it's more like this:
Previously, when the |
I guess I could also define my own |
@snargleplax sqldecoder is intended to unmarshal
|
thanks @bhcleek that was my point, sqlmock.NewRows should be used only for mocking sql database Query result Rows. Maybe that is a little confusing, since in general you create rows for sql database driver which should return it from Query, but that is exactly what sqlmock is meant for, to unit test sql database interactions. |
That did the trick, thanks guys. One more type named |
The new
Rows
struct is not backward compatible with the previousRows
interface; it's missing all of thedriver.Rows
methods. The changelog and commit message from #68 leads one to believe that was an inadvertent change.
The text was updated successfully, but these errors were encountered: