We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bcfe06e commit 88b41b6Copy full SHA for 88b41b6
stmt/stmt.go
@@ -220,7 +220,7 @@ parse:
220
case c == '\'' || c == '"':
221
b.quote = c
222
// start of dollar quoted string literal (postgres)
223
- case b.allowDollar && c == '$':
+ case b.allowDollar && c == '$' && (next == '$' || next == '_' || unicode.IsLetter(next)):
224
var id string
225
id, i, ok = readDollarAndTag(b.r, i, b.rlen)
226
if ok {
stmt/stmt_test.go
@@ -184,6 +184,10 @@ func TestNextResetState(t *testing.T) {
184
{`select 1\g '\g `, []string{`select 1`}, []string{`\g| '\g `}, "=", nil},
185
{`select 1\g "\g `, []string{`select 1`}, []string{`\g| "\g `}, "=", nil},
186
{"select 1\\g `\\g ", []string{`select 1`}, []string{"\\g| `\\g "}, "=", nil},
187
+ {"select $$\\g$$\\g", []string{`select $$\g$$`}, []string{`\g|`}, "=", nil},
188
+ {"select $1\\bind a b c\\g", []string{`select $1`}, []string{`\bind| a b c`, `\g|`}, "=", nil},
189
+ {"select $1 \\bind a b c \\g", []string{`select $1 `}, []string{`\bind| a b c `, `\g|`}, "=", nil},
190
+ {"select $2, $a$ foo $a$, $1 \\bind a b \\g", []string{`select $2, $a$ foo $a$, $1 `}, []string{`\bind| a b `, `\g|`}, "=", nil},
191
}
192
for i, test := range tests {
193
b := New(sp(test.s, "\n"), WithAllowDollar(true), WithAllowMultilineComments(true), WithAllowCComments(true))
0 commit comments