diff --git a/go.mod b/go.mod index 0aff37422295..40677c37dba0 100644 --- a/go.mod +++ b/go.mod @@ -54,7 +54,7 @@ require ( github.com/ldez/gomoddirectives v0.2.3 github.com/ldez/tagliatelle v0.3.1 github.com/leonklingele/grouper v1.1.0 - github.com/lufeee/execinquery v1.0.0 + github.com/lufeee/execinquery v1.2.0 github.com/maratori/testpackage v1.0.1 github.com/matoous/godox v0.0.0-20210227103229-6504466cf951 // v1.0 github.com/mattn/go-colorable v0.1.12 diff --git a/go.sum b/go.sum index 39da71db8641..da56c4e7fed8 100644 --- a/go.sum +++ b/go.sum @@ -503,8 +503,8 @@ github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.9.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.4/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/lufeee/execinquery v1.0.0 h1:1XUTuLIVPDlFvUU3LXmmZwHDsolsxXnY67lzhpeqe0I= -github.com/lufeee/execinquery v1.0.0/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= +github.com/lufeee/execinquery v1.2.0 h1:07LBuxOFCLoNXUuwnRxL1T+ef8rI0gYZRBe2yh9BflU= +github.com/lufeee/execinquery v1.2.0/go.mod h1:EC7DrEKView09ocscGHC+apXMIaorh4xqSxS/dy8SbM= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0/go.mod h1:zJYVVT2jmtg6P3p1VtQj7WsuWi/y4VnjVBn7F8KPB3I= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= diff --git a/pkg/golinters/execinquery.go b/pkg/golinters/execinquery.go index 11cf025e33fe..9911d315e0b3 100644 --- a/pkg/golinters/execinquery.go +++ b/pkg/golinters/execinquery.go @@ -15,5 +15,5 @@ func NewExecInQuery() *goanalysis.Linter { a.Doc, []*analysis.Analyzer{a}, nil, - ).WithLoadMode(goanalysis.LoadModeSyntax) + ).WithLoadMode(goanalysis.LoadModeTypesInfo) } diff --git a/pkg/lint/lintersdb/manager.go b/pkg/lint/lintersdb/manager.go index 434d435d03c4..9f72e6379d4e 100644 --- a/pkg/lint/lintersdb/manager.go +++ b/pkg/lint/lintersdb/manager.go @@ -271,6 +271,7 @@ func (m Manager) GetAllSupportedLinterConfigs() []*linter.Config { linter.NewConfig(golinters.NewExecInQuery()). WithSince("v1.46.0"). WithPresets(linter.PresetSQL). + WithLoadForGoAnalysis(). WithURL("https://github.com/lufeee/execinquery"), linter.NewConfig(golinters.NewExhaustive(exhaustiveCfg)). diff --git a/test/testdata/execinquery.go b/test/testdata/execinquery.go index 3b84d54fa539..2c4c742fc412 100644 --- a/test/testdata/execinquery.go +++ b/test/testdata/execinquery.go @@ -9,22 +9,22 @@ import ( 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" + _, err := db.Query("Update * FROM hoge where id = ?", test) // ERROR "Use Exec instead of Query 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" + db.QueryRow("Update * FROM hoge where id = ?", test) // ERROR "Use Exec instead of QueryRow 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 " + _, err = db.QueryContext(ctx, "Update * FROM hoge where id = ?", test) // ERROR "Use ExecContext instead of QueryContext 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" + db.QueryRowContext(ctx, "Update * FROM hoge where id = ?", test) // ERROR "Use ExecContext instead of QueryRowContext to execute `UPDATE` query" }