Skip to content

Commit 549c925

Browse files
authored
isProc: recognize builtin-commands (denisenkom#252)
* mssql: recognize builtin-commands * Update mssql_test.go * .golangci: fixed version in the config
1 parent b9933eb commit 549c925

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

.golangci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
version: "2"
12
linters:
23
enable:
34
# basic go linters
4-
- gofmt
5-
- golint
65
- govet
6+
- revive # replacing golint as it is deprecated
77

88
# sql related linters
99
- rowserrcheck

mssql.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,10 @@ func (s *Stmt) sendQuery(ctx context.Context, args []namedValue) (err error) {
563563
return
564564
}
565565

566+
// Builtin commands are not stored procs, but rather T-SQL commands
567+
// those commands can be invoke without extra options
568+
var builtinCommands = []string{"RECONFIGURE", "SHUTDOWN", "CHECKPOINT"}
569+
566570
// isProc takes the query text in s and determines if it is a stored proc name
567571
// or SQL text.
568572
func isProc(s string) bool {
@@ -621,6 +625,12 @@ func isProc(s string) bool {
621625
}
622626
}
623627
}
628+
s = strings.ToUpper(s)
629+
for _, cmd := range builtinCommands {
630+
if s == cmd {
631+
return false
632+
}
633+
}
624634
return true
625635
}
626636

mssql_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func TestIsProc(t *testing.T) {
4848
{"--proc", false},
4949
{"[proc;]", true},
5050
{" proc", false},
51+
{"RECONFIGURE", false},
52+
{"SHUTDOWN", false},
53+
{"CHECKPOINT", false},
5154
}
5255

5356
for _, item := range list {

0 commit comments

Comments
 (0)