Skip to content

Commit 30fa0cd

Browse files
Merge pull request taozhi8833998#400 from taozhi8833998/bug-multiple-prepared-statements
fix multipler prepared statements bug
2 parents 0ad0cdd + d345ca9 commit 30fa0cd

3 files changed

Lines changed: 6 additions & 2 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": "3.0.2",
3+
"version": "3.0.3",
44
"description": "simple node sql parser",
55
"main": "index.js",
66
"types": "index.d.ts",

pegjs/mysql.pegjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ primary
15831583
return list;
15841584
}
15851585
/ var_decl
1586-
/ __ prepared_symbol:'?' __ {
1586+
/ __ prepared_symbol:'?' {
15871587
return {
15881588
type: 'origin',
15891589
value: prepared_symbol

test/select.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1244,12 +1244,16 @@ describe('select', () => {
12441244
it('should parse mysql prepared statements', () => {
12451245
expect(getParsedSql('SELECT bar, baz, foo FROM tablename WHERE bar = ?'))
12461246
.to.be.equal('SELECT `bar`, `baz`, `foo` FROM `tablename` WHERE `bar` = ?')
1247+
expect(getParsedSql('SELECT bar, baz, foo FROM tablename WHERE bar = ? and baz = ?'))
1248+
.to.be.equal('SELECT `bar`, `baz`, `foo` FROM `tablename` WHERE `bar` = ? AND `baz` = ?')
12471249
})
12481250

12491251
it('should parse pg prepared statements', () => {
12501252
const opt = { database: 'postgresql' }
12511253
expect(getParsedSql('SELECT bar, baz, foo FROM tablename WHERE bar = $1', opt))
12521254
.to.be.equal('SELECT "bar", "baz", "foo" FROM "tablename" WHERE "bar" = $1', opt)
1255+
expect(getParsedSql('SELECT bar, baz, foo FROM tablename WHERE bar = $1 and baz = $2', opt))
1256+
.to.be.equal('SELECT "bar", "baz", "foo" FROM "tablename" WHERE "bar" = $1 AND "baz" = $2', opt)
12531257
})
12541258
})
12551259

0 commit comments

Comments
 (0)