DATA-DOG / go-sqlmock

Sql mock driver for golang to test database interactions
Other
6.05k stars 406 forks source link

SQL Mock driver can not identify number of parameters in insert statement when exec is used #211

Closed ms-clovis closed 4 years ago

ms-clovis commented 4 years ago

`db, mock, err := sqlmock.New()

if err != nil { t.Fatalf("an error '%s' was not expected when opening a stub database connection", err) }

.......

mock.ExpectExec("INSERT").WithArgs(snippet). // matching insert := "INSERT INTO snippets(title,content,created,expires) VALUES" +"( ? , ? , ? , ?)" WillReturnResult(sqlmock.NewResult(0,1)) `

returns an error where the number of question marks (parameter placeholders) in sql is 1

see go version go1.13.4 windows/amd64 sql package convert.go line 110

ms-clovis commented 4 years ago

Found issue , apologies!