NamedArgs allows underscore
This commit is contained in:
+1
-1
@@ -128,7 +128,7 @@ func namedArgState(l *sqlLexer) stateFn {
|
||||
l.start = l.pos
|
||||
}
|
||||
return nil
|
||||
} else if !(isLetter(r) || (r >= '0' && r <= '9')) {
|
||||
} else if !(isLetter(r) || (r >= '0' && r <= '9') || r == '_') {
|
||||
l.pos -= width
|
||||
na := namedArg(l.src[l.start:l.pos])
|
||||
if _, found := l.nameToOrdinal[na]; !found {
|
||||
|
||||
@@ -36,6 +36,12 @@ func TestNamedArgsRewriteQuery(t *testing.T) {
|
||||
expectedSQL: "select $1::int, $2::text",
|
||||
expectedArgs: []any{int32(42), "foo"},
|
||||
},
|
||||
{
|
||||
sql: "select @Abc::int, @b_4::text",
|
||||
namedArgs: pgx.NamedArgs{"Abc": int32(42), "b_4": "foo"},
|
||||
expectedSQL: "select $1::int, $2::text",
|
||||
expectedArgs: []any{int32(42), "foo"},
|
||||
},
|
||||
{
|
||||
sql: "at end @",
|
||||
namedArgs: pgx.NamedArgs{"a": int32(42), "b": "foo"},
|
||||
|
||||
Reference in New Issue
Block a user