Skip to content

Commit c5b38c6

Browse files
committed
support pn ctrl
1 parent e4194d2 commit c5b38c6

6 files changed

Lines changed: 16 additions & 5 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-sql-parser",
3-
"version": "1.6.21",
3+
"version": "1.6.22",
44
"description": "simple node sql parser",
55
"main": "index.js",
66
"types": "index.d.ts",

pegjs/hive.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1685,7 +1685,7 @@ single_quote_char
16851685
/ escape_char
16861686

16871687
single_char
1688-
= [^'\\\0-\x1F\x7f]
1688+
= [^'\\]
16891689
/ escape_char
16901690

16911691
escape_char

pegjs/mariadb.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ single_quote_char
16781678
/ escape_char
16791679

16801680
single_char
1681-
= [^'\\\0-\x1F\x7f]
1681+
= [^'\\]
16821682
/ escape_char
16831683

16841684
escape_char

pegjs/mysql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1699,7 +1699,7 @@ single_quote_char
16991699
/ escape_char
17001700

17011701
single_char
1702-
= [^'\\\0-\x1F\x7f]
1702+
= [^'\\] // remove \0-\x1F\x7f pnCtrl char [^'\\\0-\x1F\x7f]
17031703
/ escape_char
17041704

17051705
escape_char

pegjs/postgresql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ single_quote_char
16921692
/ escape_char
16931693

16941694
single_char
1695-
= [^'\\\0-\x1F\x7f]
1695+
= [^'\\]
16961696
/ escape_char
16971697

16981698
escape_char

test/insert.spec.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,15 @@ describe('insert', () => {
133133
const backSQL = parser.sqlify(ast)
134134
expect(backSQL).to.be.equal("INSERT INTO `account` (`date`, `id`) VALUES ('2019-12-23',123) RETURNING `id`")
135135
})
136+
137+
describe('support ascii pnCtrl single-char', () => {
138+
it.only('should support ascii pnCtrl', () => {
139+
// 0~31及127(共33个)是控制字符或通信专用字符 \0-\x1F和\x7f in ascii, ETX ascii code is 0x03
140+
const sql = `INSERT INTO posts (content) VALUES('\\'s ')`
141+
const ast = parser.astify(sql)
142+
const backSQL = parser.sqlify(ast)
143+
expect(backSQL).to.be.equal("INSERT INTO `posts` (`content`) VALUES ('\\'s ')")
144+
})
145+
146+
})
136147
});

0 commit comments

Comments
 (0)