-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathexecinquery.go
30 lines (23 loc) · 901 Bytes
/
execinquery.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// args: -Eexecinquery
package testdata
import (
"context"
"database/sql"
)
func execInQuery(db *sql.DB) {
test := "a"
_, err := db.Query("Update * FROM hoge where id = ?", test) // ERROR "It's better to use Execute method instead of Query method to execute `UPDATE` query"
if err != nil {
return
}
db.QueryRow("Update * FROM hoge where id = ?", test) // ERROR "It's better to use Execute method instead of QueryRow method to execute `UPDATE` query"
if err != nil {
return
}
ctx := context.Background()
_, err = db.QueryContext(ctx, "Update * FROM hoge where id = ?", test) // ERROR "It's better to use Execute method instead of QueryContext method to execute `UPDATE` query "
if err != nil {
return
}
db.QueryRowContext(ctx, "Update * FROM hoge where id = ?", test) // ERROR "It's better to use Execute method instead of QueryRowContext method to execute `UPDATE` query"
}