mirror of https://github.com/jackc/pgx.git
NamedArgs allows underscore
parent
c093c4af21
commit
d13bdbbd35
|
@ -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"},
|
||||
|
|
Loading…
Reference in New Issue