Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sqlParser.jison
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ UNION return 'UNION'
"}" return '}'
";" return ';'

['](\\.|[^'])*['] return 'STRING'
["](\\.|[^"])*["] return 'STRING'
['](['][']|\\.|[^'])*['] return 'STRING'
["](["]["]|\\.|[^"])*["] return 'STRING'
[0][x][0-9a-fA-F]+ return 'HEX_NUMERIC'
[-]?[0-9]+(\.[0-9]+)? return 'NUMERIC'
[-]?[0-9]+(\.[0-9]+)?[eE][-][0-9]+(\.[0-9]+)? return 'EXPONENT_NUMERIC'
Expand Down
11 changes: 11 additions & 0 deletions test/main.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,15 @@ describe('select grammar support', function () {
SELECT one.name, group_concat(j.value, ', ') FROM one, json_each(one.stringArray) AS j GROUP BY one.id
`)
})

it('support SQL-standard doubled quotes inside string literals', function () {
const ast = testParser("select * from t where name = 'O''Hare'");
assert.equal(ast.value.where.right.value, "'O''Hare'");

const astDouble = testParser('select * from t where name = "say ""hi"""');
assert.equal(astDouble.value.where.right.value, '"say ""hi"""');

// empty string and backslash escapes should keep working
testParser("select * from t where a = '' and b = 'O\\'Hare'");
})
});