Closed afzalabbasi closed 5 months ago
Please post some example code working on the Go Playground. Here is a template.
Same issue, have you fixed it?
Facing same issue. Any updates?
Hi @afzalabbasi! It looks like you're using ExpectExec
for a SELECT, which should typically be modeled with a Query
, QueryContext
, QueryRow
, QueryRowContext
. The code you provide is using a Get
method, which is not part of the standard library's database/sql
package, so it's harder to know what your Get
method is doing. Maybe you're using a wrapper library like gorm or sqlx? If that's the case and your wrapper library is transalting to any of the 4 Query
* methods then you should use ExpectQuery
instead of ExpectExec
.
I hope that helps, closing as this seems related to usage of an external library. If the problem persists, reopen and provide the following information:
sqlmock
version.Thank you!
hey All mock.ExpectExec("SELECT FROM permission WHERE roleid = $1").WithArgs(2) this is my mock queey i just compare that one with the original query which one is db.Get(&programinfo, "SELECT FROM permission WHERE roleid = $1", roleid) but i found that error call to Query 'SELECT * FROM permission WHERE roleid = $1' with args [{Name: Ordinal:1 Value:2}], was not expected, next expectation is: ExpectedExec => expecting Exec or ExecContext which: