mirror of https://github.com/jackc/pgx.git
Fix single line comment for line endings in mac when sanitizing.
parent
b6b24f9e8a
commit
a86ece025c
|
@ -246,7 +246,7 @@ func oneLineCommentState(l *sqlLexer) stateFn {
|
||||||
case '\\':
|
case '\\':
|
||||||
_, width = utf8.DecodeRuneInString(l.src[l.pos:])
|
_, width = utf8.DecodeRuneInString(l.src[l.pos:])
|
||||||
l.pos += width
|
l.pos += width
|
||||||
case '\n':
|
case '\n', '\r':
|
||||||
return rawState
|
return rawState
|
||||||
case utf8.RuneError:
|
case utf8.RuneError:
|
||||||
if l.pos-l.start > 0 {
|
if l.pos-l.start > 0 {
|
||||||
|
|
|
@ -77,12 +77,16 @@ func TestNewQuery(t *testing.T) {
|
||||||
expected: sanitize.Query{Parts: []sanitize.Part{"select -- a baby's toy\n'barbie', ", 1}},
|
expected: sanitize.Query{Parts: []sanitize.Part{"select -- a baby's toy\n'barbie', ", 1}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sql: "select 42 -- is a Thinker's favorite number",
|
sql: "select 42 -- is a Deep Thought's favorite number",
|
||||||
expected: sanitize.Query{Parts: []sanitize.Part{"select 42 -- is a Thinker's favorite number"}},
|
expected: sanitize.Query{Parts: []sanitize.Part{"select 42 -- is a Deep Thought's favorite number"}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
sql: "select 42, -- \\nis a Thinker's favorite number\n$1",
|
sql: "select 42, -- \\nis a Deep Thought's favorite number\n$1",
|
||||||
expected: sanitize.Query{Parts: []sanitize.Part{"select 42, -- \\nis a Thinker's favorite number\n", 1}},
|
expected: sanitize.Query{Parts: []sanitize.Part{"select 42, -- \\nis a Deep Thought's favorite number\n", 1}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
sql: "select 42, -- \\nis a Deep Thought's favorite number\r$1",
|
||||||
|
expected: sanitize.Query{Parts: []sanitize.Part{"select 42, -- \\nis a Deep Thought's favorite number\r", 1}},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue