pgsql-ast-parser
Advanced tools
Comparing version 9.3.0 to 9.3.1
@@ -137,2 +137,3 @@ import * as a from './syntax/ast'; | ||
wrapped?: IAstPartialMapper; | ||
skipNext?: boolean; | ||
super(): SkipModifier; | ||
@@ -139,0 +140,0 @@ statement(val: a.Statement): a.Statement | nil; |
{ | ||
"name": "pgsql-ast-parser", | ||
"version": "9.3.0", | ||
"version": "9.3.1", | ||
"description": "Yet another simple Postgres SQL parser/modifier", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -201,3 +201,20 @@ import 'mocha'; | ||
it('maps insert with super() call', () => { | ||
// create a mapper | ||
const mapper = astMapper(map => ({ | ||
insert: i => map.super().insert({ | ||
...i, | ||
columns: i.columns?.filter(c => c.name !== 'a'), | ||
}) | ||
})) | ||
const source = parseFirst(`insert into test (a, b) values ('a', 'b')`); | ||
const target = parseFirst(`insert into test (b) values ('a', 'b')`); | ||
const mapped = mapper.statement(source); | ||
expect(mapped).to.deep.equal(target); | ||
}) | ||
it('runs deno test - match', () => { | ||
@@ -204,0 +221,0 @@ const mapper = astMapper(map => ({ |
@@ -209,2 +209,3 @@ import * as a from './syntax/ast'; | ||
wrapped?: IAstPartialMapper; | ||
skipNext?: boolean; | ||
@@ -1268,2 +1269,6 @@ super() { | ||
return function (this: AstDefaultMapper, ...args: []) { | ||
if (this.skipNext) { | ||
this.skipNext = false; | ||
return orig.apply(this, args); | ||
} | ||
const impl = (this.wrapped as any)?.[k]; | ||
@@ -1296,3 +1301,4 @@ if (!impl) { | ||
return function (this: SkipModifier, ...args: []) { | ||
return orig.apply(this.parent.wrapped, args); | ||
this.parent.skipNext = true; | ||
return orig.apply(this.parent, args); | ||
} | ||
@@ -1299,0 +1305,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
1525837
16817