From abdb3bf8b3cd5cd55b2400f155814172f553e73e Mon Sep 17 00:00:00 2001 From: David Shiflet Date: Thu, 12 Dec 2024 12:19:18 -0600 Subject: [PATCH] Fix: Make colon optional for reset (#559) --- pkg/sqlcmd/commands.go | 2 +- pkg/sqlcmd/commands_test.go | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/pkg/sqlcmd/commands.go b/pkg/sqlcmd/commands.go index 9bf0b9d9..66dd1dba 100644 --- a/pkg/sqlcmd/commands.go +++ b/pkg/sqlcmd/commands.go @@ -77,7 +77,7 @@ func newCommands() Commands { name: "LISTVAR", }, "RESET": { - regex: regexp.MustCompile(`(?im)^[ \t]*:RESET(?:[ \t]+(.*$)|$)`), + regex: regexp.MustCompile(`(?im)^[ \t]*?:?RESET(?:[ \t]+(.*$)|$)`), action: resetCommand, name: "RESET", }, diff --git a/pkg/sqlcmd/commands_test.go b/pkg/sqlcmd/commands_test.go index 7d2acb4e..c136d8a2 100644 --- a/pkg/sqlcmd/commands_test.go +++ b/pkg/sqlcmd/commands_test.go @@ -53,6 +53,8 @@ func TestCommandParsing(t *testing.T) { {` !! dir c:\`, "EXEC", []string{` dir c:\`}}, {`!!dir c:\`, "EXEC", []string{`dir c:\`}}, {`:XML ON `, "XML", []string{`ON `}}, + {`:RESET`, "RESET", []string{""}}, + {`RESET`, "RESET", []string{""}}, } for _, test := range commands {