Skip to content

Commit 8d13122

Browse files
authored
allow var names to start with _ (#195)
1 parent 403f8eb commit 8d13122

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

pkg/sqlcmd/variables.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ func ValidIdentifier(name string) error {
285285

286286
first := true
287287
for _, c := range name {
288-
if !unicode.IsLetter(c) && (first || (!unicode.IsDigit(c) && !strings.ContainsRune(validVariableRunes, c))) {
288+
if !unicode.IsLetter(c) && c != '_' && (first || (!unicode.IsDigit(c) && !strings.ContainsRune(validVariableRunes, c))) {
289289
return fmt.Errorf("Invalid variable identifier %s", name)
290290
}
291291
first = false

pkg/sqlcmd/variables_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ func TestValidIdentifier(t *testing.T) {
104104
{"A1", true},
105105
{"A+", false},
106106
{"A-_b", true},
107+
{"__X", true},
107108
}
108109
for _, tst := range tests {
109110
err := ValidIdentifier(tst.raw)

0 commit comments

Comments
 (0)