-
-
Notifications
You must be signed in to change notification settings - Fork 407
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
Sql mismatch #343
Comments
I used sqlmock.AnyArg() to map creation time and modification time, but still got sql mismatch error |
Is your query escaped correctly? q := "SELECT \\* FROM `arg_configs` WHERE arg_key = \\? ORDER BY `arg_configs`.`id` LIMIT \\?" Want: q:= `SELECT \* FROM "arg_configs" WHERE arg_key = \? ORDER BY 'arg_configs'\.'id' LIMIT \?` |
@ivorytower1026 I think the problem might be caused by gorm's ID field and it's related to this issue: go-gorm/gorm#7042 I can see you're using mysql though, so I'm not sure if it's actually related. Try adding a row and using dbMock.ExpectBegin()
addRow := sqlmock.NewRows([]string{"id"}).AddRow("1")
dbMock.ExpectQuery(`INSERT INTO "arg_configs" (.+) VALUES (.+) RETURNING "id"`).WillReturnRows(addRow)
dbMock.ExpectCommit() |
Sql Mismatch
Here is my output error
Method under test
The code that caused the error
Test file
ArgConfig model
BaseModel
The text was updated successfully, but these errors were encountered: