Skip to content

Commit

Permalink
PG statement returning string with escaped backslash
Browse files Browse the repository at this point in the history
  • Loading branch information
pihvi committed Apr 2, 2023
1 parent df2aeca commit 2ca7e32
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,3 +256,10 @@ it('PG comments with tokens and quotes', () => {
$3 ::INT[]`.trim()
assert.deepEqual(res, {text, values: [5, 5, 5]})
})

it('PG statement returning string with escaped backslash', () => {
const query = `select 'C:\\work' as path`
const res = yesql.pg(query)()
const text = `select 'C:\\work' as path`
assert.deepEqual(res, {text, values: []})
})
2 changes: 1 addition & 1 deletion yesql.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const readSqlFiles = (dir, options = {}) => {

const pg = (query, options = {}) => {
return (data = {}) => {
const matchQuoted = /('[^'\\]*(\\.[^'\\]*)*')/
const matchQuoted = /('[^']*(\\.[^'\\]*)*')/
const matchDoubleQuoted = /("[^"\\]*(\\.[^"\\]*)*")/
const values = []

Expand Down

0 comments on commit 2ca7e32

Please sign in to comment.