@memberjunction/sql-parser 5.36.0 → 5.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ASTDialectAdapter.d.ts +58 -0
- package/dist/ASTDialectAdapter.d.ts.map +1 -0
- package/dist/ASTDialectAdapter.js +113 -0
- package/dist/ASTDialectAdapter.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/sql-parser.d.ts +234 -4
- package/dist/sql-parser.d.ts.map +1 -1
- package/dist/sql-parser.js +765 -9
- package/dist/sql-parser.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ASTDialectAdapter — dialect-specific node-sql-parser AST field shapes.
|
|
3
|
+
*
|
|
4
|
+
* The only AST field that genuinely varies in shape between dialects is the
|
|
5
|
+
* row cap: SQL Server uses `root.top`, PostgreSQL / MySQL use `root.limit`.
|
|
6
|
+
* Each adapter encapsulates the read/write/clear logic for its dialect's row
|
|
7
|
+
* cap. Everything else (CTEs, set-ops, ORDER BY, SELECT INTO, FOR JSON/XML)
|
|
8
|
+
* has an identical AST shape across dialects and is handled directly by
|
|
9
|
+
* SQLParser — no adapter needed.
|
|
10
|
+
*
|
|
11
|
+
* Internal to @memberjunction/sql-parser. The adapters themselves are NOT
|
|
12
|
+
* exported; consumers see only the dialect-neutral {@link RowCapInfo} return
|
|
13
|
+
* type and the resolver. This keeps node-sql-parser's AST shape knowledge
|
|
14
|
+
* confined to this one file.
|
|
15
|
+
*/
|
|
16
|
+
import type { SQLParserDialect } from '@memberjunction/sql-dialect';
|
|
17
|
+
/**
|
|
18
|
+
* Dialect-neutral description of a row cap found on a SELECT statement.
|
|
19
|
+
*
|
|
20
|
+
* There is deliberately no TOP/LIMIT naming — consumers don't need to know
|
|
21
|
+
* which syntax form produced the cap. The explicit `form` discriminant keeps
|
|
22
|
+
* narrowing robust: a future variant cannot silently break an `in`-based guard.
|
|
23
|
+
*/
|
|
24
|
+
export type RowCapInfo =
|
|
25
|
+
/** Numeric cap — comparable against a requested row limit. */
|
|
26
|
+
{
|
|
27
|
+
form: 'numeric';
|
|
28
|
+
value: number;
|
|
29
|
+
offset: number | null;
|
|
30
|
+
}
|
|
31
|
+
/** Percentage cap (SQL Server `TOP N PERCENT`) — a fraction, not a row count. */
|
|
32
|
+
| {
|
|
33
|
+
form: 'percent';
|
|
34
|
+
}
|
|
35
|
+
/** Non-numeric expression (`TOP (@var)`, `LIMIT $1`) — not statically known. */
|
|
36
|
+
| {
|
|
37
|
+
form: 'opaque';
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Encapsulates one dialect's row-cap AST field shape. An instance of SQLParser
|
|
41
|
+
* binds exactly one dialect and therefore one adapter, so a TOP-form AST is
|
|
42
|
+
* never read/written through a LIMIT-form adapter (and vice versa).
|
|
43
|
+
*/
|
|
44
|
+
export interface ASTDialectAdapter {
|
|
45
|
+
/** Read the outermost row cap from an AST root node, or null when none. */
|
|
46
|
+
ReadRowCap(root: Record<string, unknown>): RowCapInfo | null;
|
|
47
|
+
/** Write a numeric row cap onto an AST root node (preserving any OFFSET). */
|
|
48
|
+
WriteRowCap(root: Record<string, unknown>, cap: number): void;
|
|
49
|
+
/** Remove the row cap from an AST root node. */
|
|
50
|
+
ClearRowCap(root: Record<string, unknown>): void;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Resolves the AST adapter for a dialect. Throws when none is registered —
|
|
54
|
+
* a developer error (a dialect was added to sql-dialect without a matching
|
|
55
|
+
* adapter here).
|
|
56
|
+
*/
|
|
57
|
+
export declare function getASTDialectAdapter(dialect: SQLParserDialect): ASTDialectAdapter;
|
|
58
|
+
//# sourceMappingURL=ASTDialectAdapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ASTDialectAdapter.d.ts","sourceRoot":"","sources":["../src/ASTDialectAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;;GAMG;AACH,MAAM,MAAM,UAAU;AAClB,8DAA8D;AAC5D;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE;AAC3D,iFAAiF;GAC/E;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE;AACrB,gFAAgF;GAC9E;IAAE,IAAI,EAAE,QAAQ,CAAA;CAAE,CAAC;AAEzB;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAC9B,2EAA2E;IAC3E,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,GAAG,IAAI,CAAC;IAC7D,6EAA6E;IAC7E,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9D,gDAAgD;IAChD,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CACpD;AA4FD;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,GAAG,iBAAiB,CASjF"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ASTDialectAdapter — dialect-specific node-sql-parser AST field shapes.
|
|
3
|
+
*
|
|
4
|
+
* The only AST field that genuinely varies in shape between dialects is the
|
|
5
|
+
* row cap: SQL Server uses `root.top`, PostgreSQL / MySQL use `root.limit`.
|
|
6
|
+
* Each adapter encapsulates the read/write/clear logic for its dialect's row
|
|
7
|
+
* cap. Everything else (CTEs, set-ops, ORDER BY, SELECT INTO, FOR JSON/XML)
|
|
8
|
+
* has an identical AST shape across dialects and is handled directly by
|
|
9
|
+
* SQLParser — no adapter needed.
|
|
10
|
+
*
|
|
11
|
+
* Internal to @memberjunction/sql-parser. The adapters themselves are NOT
|
|
12
|
+
* exported; consumers see only the dialect-neutral {@link RowCapInfo} return
|
|
13
|
+
* type and the resolver. This keeps node-sql-parser's AST shape knowledge
|
|
14
|
+
* confined to this one file.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* SQL Server: row caps live on `root.top = { value, percent }`.
|
|
18
|
+
*/
|
|
19
|
+
class TransactSQLAdapter {
|
|
20
|
+
ReadRowCap(root) {
|
|
21
|
+
const top = root.top;
|
|
22
|
+
if (top == null)
|
|
23
|
+
return null;
|
|
24
|
+
if (top.percent)
|
|
25
|
+
return { form: 'percent' };
|
|
26
|
+
const v = typeof top.value === 'number' ? top.value : Number(top.value);
|
|
27
|
+
if (!Number.isFinite(v))
|
|
28
|
+
return { form: 'opaque' };
|
|
29
|
+
return { form: 'numeric', value: v, offset: null };
|
|
30
|
+
}
|
|
31
|
+
WriteRowCap(root, cap) {
|
|
32
|
+
root.top = { value: cap, percent: null };
|
|
33
|
+
}
|
|
34
|
+
ClearRowCap(root) {
|
|
35
|
+
root.top = null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* PostgreSQL / MySQL: row caps live on `root.limit`.
|
|
40
|
+
*
|
|
41
|
+
* node-sql-parser shape:
|
|
42
|
+
* LIMIT N → value=[{value:N}], seperator=''
|
|
43
|
+
* LIMIT N OFFSET M → value=[{value:N}, {value:M}], seperator='offset'
|
|
44
|
+
* The LIMIT value is always at index 0 in these dialects.
|
|
45
|
+
*/
|
|
46
|
+
class LimitOffsetAdapter {
|
|
47
|
+
ReadRowCap(root) {
|
|
48
|
+
const limit = root.limit;
|
|
49
|
+
if (limit == null || !Array.isArray(limit.value) || limit.value.length === 0) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const limitNode = limit.value[0];
|
|
53
|
+
const v = typeof limitNode.value === 'number' ? limitNode.value : Number(limitNode.value);
|
|
54
|
+
if (!Number.isFinite(v))
|
|
55
|
+
return { form: 'opaque' };
|
|
56
|
+
let offset = null;
|
|
57
|
+
if (limit.value.length > 1) {
|
|
58
|
+
const offsetNode = limit.value[1];
|
|
59
|
+
const o = typeof offsetNode.value === 'number' ? offsetNode.value : Number(offsetNode.value);
|
|
60
|
+
offset = Number.isFinite(o) ? o : null;
|
|
61
|
+
}
|
|
62
|
+
return { form: 'numeric', value: v, offset };
|
|
63
|
+
}
|
|
64
|
+
WriteRowCap(root, cap) {
|
|
65
|
+
const existing = root.limit;
|
|
66
|
+
const offsetNode = existing?.value && existing.value.length > 1 ? existing.value[1] : null;
|
|
67
|
+
if (offsetNode) {
|
|
68
|
+
root.limit = {
|
|
69
|
+
seperator: 'offset',
|
|
70
|
+
value: [{ type: 'number', value: cap }, offsetNode],
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
root.limit = {
|
|
75
|
+
seperator: '',
|
|
76
|
+
value: [{ type: 'number', value: cap }],
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
ClearRowCap(root) {
|
|
81
|
+
root.limit = null;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Maps node-sql-parser dialect strings (the value passed to node-sql-parser,
|
|
86
|
+
* exposed as `SQLParserDialect.ParserDialect`) to their adapter. This is the
|
|
87
|
+
* correct key because it identifies exactly which AST shape the parser
|
|
88
|
+
* produces.
|
|
89
|
+
*
|
|
90
|
+
* A plain Map, not MJGlobal.ClassFactory: these adapters are internal, tightly
|
|
91
|
+
* coupled to undocumented node-sql-parser internals, form a closed set (adding
|
|
92
|
+
* a dialect always touches this file anyway), and cannot be meaningfully
|
|
93
|
+
* overridden by an external consumer.
|
|
94
|
+
*/
|
|
95
|
+
const ADAPTERS = new Map([
|
|
96
|
+
['TransactSQL', new TransactSQLAdapter()],
|
|
97
|
+
['PostgresQL', new LimitOffsetAdapter()],
|
|
98
|
+
['MySQL', new LimitOffsetAdapter()],
|
|
99
|
+
]);
|
|
100
|
+
/**
|
|
101
|
+
* Resolves the AST adapter for a dialect. Throws when none is registered —
|
|
102
|
+
* a developer error (a dialect was added to sql-dialect without a matching
|
|
103
|
+
* adapter here).
|
|
104
|
+
*/
|
|
105
|
+
export function getASTDialectAdapter(dialect) {
|
|
106
|
+
const adapter = ADAPTERS.get(dialect.ParserDialect);
|
|
107
|
+
if (!adapter) {
|
|
108
|
+
throw new Error(`No ASTDialectAdapter registered for ParserDialect "${dialect.ParserDialect}". ` +
|
|
109
|
+
`Register one in packages/SQLParser/src/ASTDialectAdapter.ts when adding a new dialect.`);
|
|
110
|
+
}
|
|
111
|
+
return adapter;
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=ASTDialectAdapter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ASTDialectAdapter.js","sourceRoot":"","sources":["../src/ASTDialectAdapter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAiCH;;GAEG;AACH,MAAM,kBAAkB;IACpB,UAAU,CAAC,IAA6B;QACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAgE,CAAC;QAClF,IAAI,GAAG,IAAI,IAAI;YAAE,OAAO,IAAI,CAAC;QAC7B,IAAI,GAAG,CAAC,OAAO;YAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC;QAC5C,MAAM,CAAC,GAAG,OAAO,GAAG,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACxE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QACnD,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE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oBAAoB,CAAC,OAAyB;IAC1D,MAAM,OAAO,GAAG,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IACpD,IAAI,CAAC,OAAO,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CACX,sDAAsD,OAAO,CAAC,aAAa,KAAK;YAChF,wFAAwF,CAC3F,CAAC;IACN,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export { AnalyzeTopLevelOrderBy, HasTopLevelOrderBy, ExtractOrderBy, findOrderBy
|
|
|
4
4
|
export type { OrderByAnalysis } from './orderByAnalyzer.js';
|
|
5
5
|
export { ParseToIR, RenderIR } from './structuralParser.js';
|
|
6
6
|
export type { QueryIR, CTENode, Fragment, SQLFragment, TemplateExprFragment, BlockFragment, CommentFragment, CompositionRefFragment, CTEOrigin } from './compositionIR.js';
|
|
7
|
-
export type { MJAstifyResult, SQLTableReference, SQLColumnReference, SQLSelectColumn, SQLCTEExtraction, MJParameterInfo, SQLParseResult, SQLParseOptions, } from './sql-parser.js';
|
|
7
|
+
export type { MJAstifyResult, SQLTableReference, SQLColumnReference, SQLSelectColumn, SQLCTEExtraction, MJParameterInfo, SQLParseResult, SQLParseOptions, SQLStatementKind, RowCapInfo, } from './sql-parser.js';
|
|
8
8
|
export type { AST as SQLAst } from 'node-sql-parser';
|
|
9
9
|
export type { MJNode, MJNodeType, MJTemplateExpr, MJFilter, MJCompositionRef, MJCompositionParam, MJConditionalBlock, MJBranch, MJLoopBlock, MJComment, MJSetBlock, MJSQLFragment, MJRawSQL, MJTokenType, MJToken, MJTokenParsedContent, MJTemplateExprContent, MJCompositionRefContent, MJBlockTagContent, MJCommentContent, MJSetContent, MJSQLTextContent, PlaceholderContext, PlaceholderEntry, PlaceholderSubstitutionResult, MJParseResult, SQLClauseContext, MJASTAnnotation, MJASTWalkResult, } from './mj-ast-types.js';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7I,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3K,YAAY,EACR,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,YAAY,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,cAAc,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC7I,YAAY,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAC5D,YAAY,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,oBAAoB,EAAE,aAAa,EAAE,eAAe,EAAE,sBAAsB,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC3K,YAAY,EACR,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,UAAU,GACb,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EAAE,GAAG,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGrD,YAAY,EAER,MAAM,EACN,UAAU,EACV,cAAc,EACd,QAAQ,EACR,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,QAAQ,EACR,WAAW,EACX,SAAS,EACT,UAAU,EACV,aAAa,EACb,QAAQ,EAER,WAAW,EACX,OAAO,EACP,oBAAoB,EACpB,qBAAqB,EACrB,uBAAuB,EACvB,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,gBAAgB,EAEhB,kBAAkB,EAClB,gBAAgB,EAChB,6BAA6B,EAE7B,aAAa,EAEb,gBAAgB,EAChB,eAAe,EACf,eAAe,GAClB,MAAM,mBAAmB,CAAC"}
|
package/dist/sql-parser.d.ts
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import NodeSqlParser from 'node-sql-parser';
|
|
16
16
|
import type { SQLParserDialect } from '@memberjunction/sql-dialect';
|
|
17
|
+
import { type RowCapInfo } from './ASTDialectAdapter.js';
|
|
17
18
|
import { MJToken, MJTemplateExpr, MJCompositionRef, MJConditionalBlock, MJFilter, PlaceholderEntry, PlaceholderSubstitutionResult, MJParseResult, MJASTWalkResult } from './mj-ast-types.js';
|
|
18
19
|
/** Result of Astify — the full parsed representation of MJ SQL */
|
|
19
20
|
export interface MJAstifyResult {
|
|
@@ -96,6 +97,31 @@ export interface SQLParseOptions {
|
|
|
96
97
|
/** SQL dialect for parsing and identifier quoting */
|
|
97
98
|
dialect?: SQLParserDialect;
|
|
98
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* High-level classification of the statement at the root of a parsed AST.
|
|
102
|
+
*
|
|
103
|
+
* Callers that need to decide whether a statement can be safely modified
|
|
104
|
+
* (row caps, paging, etc.) use this in preference to inspecting AST shapes
|
|
105
|
+
* directly.
|
|
106
|
+
*/
|
|
107
|
+
export type SQLStatementKind =
|
|
108
|
+
/** Plain SELECT */
|
|
109
|
+
'select'
|
|
110
|
+
/** SELECT … INTO #tmp FROM … — a write disguised as a SELECT */
|
|
111
|
+
| 'select-into'
|
|
112
|
+
/** UNION / INTERSECT / EXCEPT */
|
|
113
|
+
| 'set-op'
|
|
114
|
+
/** INSERT / UPDATE / DELETE / MERGE / etc. */
|
|
115
|
+
| 'mutation'
|
|
116
|
+
/** Anything else or an unrecognized shape */
|
|
117
|
+
| 'other';
|
|
118
|
+
/**
|
|
119
|
+
* Dialect-neutral description of the outermost row cap on a parsed SELECT.
|
|
120
|
+
* Defined in {@link ./ASTDialectAdapter}; re-exported here so consumers can
|
|
121
|
+
* import it from `@memberjunction/sql-parser` without referencing the adapter.
|
|
122
|
+
* Returned by {@link SQLParser.OuterCap}.
|
|
123
|
+
*/
|
|
124
|
+
export type { RowCapInfo } from './ASTDialectAdapter.js';
|
|
99
125
|
/**
|
|
100
126
|
* Unified parser for MemberJunction's SQL superset.
|
|
101
127
|
*
|
|
@@ -103,9 +129,44 @@ export interface SQLParseOptions {
|
|
|
103
129
|
* Nunjucks block tags (`{% if %}...{% endif %}`), composition tokens
|
|
104
130
|
* (`{{query:"Path/Name(params)"}}`), and template comments (`{# ... #}`).
|
|
105
131
|
*
|
|
106
|
-
*
|
|
132
|
+
* Two-tier API:
|
|
133
|
+
* - **Instance** (`new SQLParser(sql, dialect)`) — parses once (with a
|
|
134
|
+
* preprocessing fallback) and exposes typed, dialect-neutral AST
|
|
135
|
+
* inspection/mutation (`StatementKind`, `OuterCap`, `SetOuterCap`,
|
|
136
|
+
* `ToSQL`) plus extraction helpers (`ExtractCTEs`, `ExtractTableRefs`,
|
|
137
|
+
* `ExtractColumnRefs`, `ExtractSelectColumns`).
|
|
138
|
+
* - **Static utilities** — pure string/token operations that need no parsed
|
|
139
|
+
* state (`StripComments`, `Tokenize`, `Analyze`, `ParseSQL`, `SqlifyAST`,
|
|
140
|
+
* `HasUnwrappableTrailingClause`, the MJ-template helpers, etc.).
|
|
107
141
|
*/
|
|
108
142
|
export declare class SQLParser {
|
|
143
|
+
private readonly _sql;
|
|
144
|
+
private readonly _dialect;
|
|
145
|
+
private readonly _adapter;
|
|
146
|
+
private readonly _ast;
|
|
147
|
+
/** alias → original bracketed identifier; set when bracket preprocessing was applied */
|
|
148
|
+
private readonly _aliasMap;
|
|
149
|
+
/** trailing `OPTION (...)` clause split off during preprocessing; re-appended on ToSQL */
|
|
150
|
+
private readonly _trailingOption;
|
|
151
|
+
/**
|
|
152
|
+
* Parse SQL into an instance exposing dialect-neutral AST inspection,
|
|
153
|
+
* mutation, and extraction.
|
|
154
|
+
*
|
|
155
|
+
* On a direct-parse failure, applies preprocessing fallbacks — splitting a
|
|
156
|
+
* trailing `OPTION (...)` clause and aliasing bracket-quoted identifiers
|
|
157
|
+
* whose interior contains parser-defeating characters (`[Active People]`,
|
|
158
|
+
* `[my-cte]`) — so a wider class of SQL becomes AST-addressable. {@link ToSQL}
|
|
159
|
+
* transparently restores both transforms.
|
|
160
|
+
*
|
|
161
|
+
* Never throws on unparseable SQL — check {@link IsValid}.
|
|
162
|
+
*/
|
|
163
|
+
constructor(sql: string, dialect: SQLParserDialect);
|
|
164
|
+
/** Whether the SQL parsed into an AST (directly or via preprocessing). */
|
|
165
|
+
get IsValid(): boolean;
|
|
166
|
+
/** The raw AST. Prefer the typed accessors; this is an escape hatch. */
|
|
167
|
+
get AST(): NodeSqlParser.AST | NodeSqlParser.AST[] | null;
|
|
168
|
+
/** The dialect supplied at construction. */
|
|
169
|
+
get Dialect(): SQLParserDialect;
|
|
109
170
|
/**
|
|
110
171
|
* Fixes a known node-sql-parser bug where CAST(x AS NVARCHAR(MAX)) is
|
|
111
172
|
* serialized as CAST(x AS NVARCHARmax). Applies to NVARCHAR, VARCHAR,
|
|
@@ -142,6 +203,113 @@ export declare class SQLParser {
|
|
|
142
203
|
* This is a thin wrapper around node-sql-parser's sqlify.
|
|
143
204
|
*/
|
|
144
205
|
static SqlifyAST(ast: NodeSqlParser.AST | NodeSqlParser.AST[], dialect: SQLParserDialect): string;
|
|
206
|
+
/**
|
|
207
|
+
* High-level classification of the parsed statement:
|
|
208
|
+
* `'select'` | `'select-into'` | `'set-op'` | `'mutation'` | `'other'`.
|
|
209
|
+
*/
|
|
210
|
+
get StatementKind(): SQLStatementKind;
|
|
211
|
+
/**
|
|
212
|
+
* node-sql-parser statement `type` values that write/modify rather than read.
|
|
213
|
+
* Used by {@link HasWriteStatement} to reject such statements anywhere in a
|
|
214
|
+
* rendered read query (including a stacked injection payload).
|
|
215
|
+
*/
|
|
216
|
+
private static readonly WRITE_STATEMENT_TYPES;
|
|
217
|
+
/**
|
|
218
|
+
* Whether ANY top-level statement is a write — a DML mutation
|
|
219
|
+
* (INSERT/UPDATE/DELETE/MERGE/REPLACE), DDL (DROP/CREATE/ALTER/TRUNCATE/
|
|
220
|
+
* RENAME), or EXEC/CALL/GRANT/REVOKE/USE.
|
|
221
|
+
*
|
|
222
|
+
* Unlike {@link StatementKind} (which classifies only the first statement),
|
|
223
|
+
* this inspects EVERY top-level statement, so a stacked payload such as
|
|
224
|
+
* `SELECT 1; DROP TABLE x` is detected. Benign session prefixes (`SET`,
|
|
225
|
+
* `DECLARE`) and SELECTs are not writes. Matching is on the AST statement
|
|
226
|
+
* type, so the `REPLACE()` string function inside a SELECT is never
|
|
227
|
+
* mistaken for a `REPLACE` statement.
|
|
228
|
+
*/
|
|
229
|
+
get HasWriteStatement(): boolean;
|
|
230
|
+
/**
|
|
231
|
+
* The outermost row cap on the parsed SELECT, dialect-neutral, or `null`
|
|
232
|
+
* when none is present. Backed by the dialect's ASTDialectAdapter, so the
|
|
233
|
+
* caller never needs to know whether the cap was a `TOP` or `LIMIT`.
|
|
234
|
+
*/
|
|
235
|
+
get OuterCap(): RowCapInfo | null;
|
|
236
|
+
/**
|
|
237
|
+
* Sets the outermost row cap. The adapter writes the dialect's form
|
|
238
|
+
* (`TOP N` on SQL Server, `LIMIT N` elsewhere), preserving any existing
|
|
239
|
+
* OFFSET. No-op when the root isn't a SELECT.
|
|
240
|
+
*/
|
|
241
|
+
SetOuterCap(cap: number): void;
|
|
242
|
+
/**
|
|
243
|
+
* Removes the outermost row cap (TOP on SQL Server, LIMIT on PostgreSQL)
|
|
244
|
+
* from the parsed SELECT. No-op when the root isn't a SELECT.
|
|
245
|
+
*
|
|
246
|
+
* Used by the count-SQL builder (`queryPagingEngine.stripCountBody`) so a
|
|
247
|
+
* paged query's count reflects the full set rather than the capped subset.
|
|
248
|
+
* It clears both forms, so a PostgreSQL count drops an explicit `LIMIT` —
|
|
249
|
+
* consistent with how SQL Server's `TOP` is dropped.
|
|
250
|
+
*/
|
|
251
|
+
ClearOuterCap(): void;
|
|
252
|
+
/**
|
|
253
|
+
* Removes the top-level ORDER BY from the parsed statement, following the
|
|
254
|
+
* set-op (`UNION` / `INTERSECT` / `EXCEPT`) chain so an ORDER BY on any
|
|
255
|
+
* branch is cleared. No-op when there is none. Dialect-universal — the
|
|
256
|
+
* `orderby` field has the same shape across dialects.
|
|
257
|
+
*
|
|
258
|
+
* Used by the count-SQL builder: ORDER BY is irrelevant for a COUNT and is
|
|
259
|
+
* illegal inside a SQL Server CTE without TOP.
|
|
260
|
+
*/
|
|
261
|
+
ClearOrderBy(): void;
|
|
262
|
+
/**
|
|
263
|
+
* Serialize the (possibly mutated) AST back to SQL, restoring any
|
|
264
|
+
* preprocessing transforms applied at construction (bracket-identifier
|
|
265
|
+
* aliases, then the trailing `OPTION (...)` clause).
|
|
266
|
+
*
|
|
267
|
+
* Throws if the SQL was not parseable (check {@link IsValid} first).
|
|
268
|
+
*/
|
|
269
|
+
ToSQL(): string;
|
|
270
|
+
/**
|
|
271
|
+
* Internal helper: unwrap the root statement from an AST (or AST array)
|
|
272
|
+
* and present it as a mutable record. Returns `null` if the input is null
|
|
273
|
+
* or empty.
|
|
274
|
+
*/
|
|
275
|
+
private static unwrapRoot;
|
|
276
|
+
/**
|
|
277
|
+
* Token-aware scan for SQL clauses that cannot legally appear inside a
|
|
278
|
+
* derived table — wrapping a query that contains one of these in
|
|
279
|
+
* `SELECT ... FROM (<sql>) AS t` would produce invalid SQL.
|
|
280
|
+
*
|
|
281
|
+
* Detects (case-insensitive, outside string literals and quoted
|
|
282
|
+
* identifiers):
|
|
283
|
+
* - `FOR JSON …`
|
|
284
|
+
* - `FOR XML …`
|
|
285
|
+
* - `OPTION (…)`
|
|
286
|
+
*
|
|
287
|
+
* The dialect determines which identifier quoting styles are recognized
|
|
288
|
+
* (`[…]` for SQL Server, `` `…` `` for MySQL, `"…"` always).
|
|
289
|
+
*/
|
|
290
|
+
static HasUnwrappableTrailingClause(sql: string, dialect: SQLParserDialect): boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Token-aware detection of stacked statements: a statement-separating
|
|
293
|
+
* semicolon that has real content after it (outside string literals,
|
|
294
|
+
* quoted identifiers, and comments). A single trailing semicolon — or a run
|
|
295
|
+
* of them followed only by whitespace/comments — is allowed.
|
|
296
|
+
*
|
|
297
|
+
* Unlike an AST check, this fires even when the trailing payload makes the
|
|
298
|
+
* SQL unparseable (`SELECT 1; EXEC xp_cmdshell '…'`, `SELECT 1; WAITFOR
|
|
299
|
+
* DELAY '…'`), which is exactly the stacked-injection class an AST scan
|
|
300
|
+
* misses (the whole string fails to parse, so the AST is null). A rendered
|
|
301
|
+
* read query must be a single statement, so any internal `;` is rejected.
|
|
302
|
+
*/
|
|
303
|
+
static HasStackedStatements(sql: string, dialect: SQLParserDialect): boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Strip line and block comments from SQL, preserving content inside
|
|
306
|
+
* string literals and quoted identifiers. Block comments support nesting.
|
|
307
|
+
*
|
|
308
|
+
* The dialect determines which identifier quoting styles are recognized:
|
|
309
|
+
* SQL Server uses `[…]`, PostgreSQL uses `"…"`, MySQL uses `` `…` ``.
|
|
310
|
+
* Double-quoted identifiers are honored on every dialect.
|
|
311
|
+
*/
|
|
312
|
+
static StripComments(sql: string, dialect: SQLParserDialect): string;
|
|
145
313
|
/**
|
|
146
314
|
* Convert a single AST expression node to a SQL string.
|
|
147
315
|
* Useful for extracting ORDER BY terms, column expressions, etc.
|
|
@@ -186,16 +354,31 @@ export declare class SQLParser {
|
|
|
186
354
|
* @param options Parse options, or just a SQL string for backward compatibility
|
|
187
355
|
*/
|
|
188
356
|
static ParseWithTemplatePreprocessing(options: SQLParseOptions | string, dialect?: SQLParserDialect): SQLParseResult;
|
|
357
|
+
/**
|
|
358
|
+
* Extract all table/view references from this instance's SQL.
|
|
359
|
+
* Convenience delegate to the static overload.
|
|
360
|
+
*/
|
|
361
|
+
ExtractTableRefs(): SQLTableReference[];
|
|
189
362
|
/**
|
|
190
363
|
* Extract all table/view references from SQL.
|
|
191
364
|
* Handles Nunjucks templates via placeholder substitution before AST parsing.
|
|
192
365
|
*/
|
|
193
|
-
static ExtractTableRefs(sql: string, dialect
|
|
366
|
+
static ExtractTableRefs(sql: string, dialect: SQLParserDialect): SQLTableReference[];
|
|
367
|
+
/**
|
|
368
|
+
* Extract all column references from this instance's SQL.
|
|
369
|
+
* Convenience delegate to the static overload.
|
|
370
|
+
*/
|
|
371
|
+
ExtractColumnRefs(): SQLColumnReference[];
|
|
194
372
|
/**
|
|
195
373
|
* Extract all column references from SQL.
|
|
196
374
|
* Handles Nunjucks templates via placeholder substitution before AST parsing.
|
|
197
375
|
*/
|
|
198
|
-
static ExtractColumnRefs(sql: string, dialect
|
|
376
|
+
static ExtractColumnRefs(sql: string, dialect: SQLParserDialect): SQLColumnReference[];
|
|
377
|
+
/**
|
|
378
|
+
* Extract SELECT clause columns from this instance's SQL.
|
|
379
|
+
* Convenience delegate to the static overload.
|
|
380
|
+
*/
|
|
381
|
+
ExtractSelectColumns(): SQLSelectColumn[];
|
|
199
382
|
/**
|
|
200
383
|
* Extracts the SELECT clause columns with their output names, source columns, and table qualifiers.
|
|
201
384
|
*
|
|
@@ -214,6 +397,11 @@ export declare class SQLParser {
|
|
|
214
397
|
* Best-effort string representation of an AST expression node (for expression columns).
|
|
215
398
|
*/
|
|
216
399
|
private static exprToString;
|
|
400
|
+
/**
|
|
401
|
+
* Extract CTE definitions from this instance's SQL.
|
|
402
|
+
* Convenience delegate to the static overload.
|
|
403
|
+
*/
|
|
404
|
+
ExtractCTEs(): SQLCTEExtraction | null;
|
|
217
405
|
/**
|
|
218
406
|
* Extract CTE definitions from SQL starting with a WITH clause.
|
|
219
407
|
*
|
|
@@ -330,6 +518,48 @@ export declare class SQLParser {
|
|
|
330
518
|
/** Resolves overloaded Parse() args: (string, dialect?) or (options) */
|
|
331
519
|
private static resolveParseArgs;
|
|
332
520
|
private static parseSQL;
|
|
521
|
+
/**
|
|
522
|
+
* Last-resort parse used when a direct parse fails. Rewrites SQL into a
|
|
523
|
+
* form node-sql-parser accepts:
|
|
524
|
+
* 1. Split a trailing `OPTION (...)` query hint (SQL Server).
|
|
525
|
+
* 2. Alias bracket-quoted identifiers whose interior contains
|
|
526
|
+
* parser-defeating characters (`[Active People]`, `[my-cte]`).
|
|
527
|
+
*
|
|
528
|
+
* Returns the AST plus the data needed to restore the original SQL on
|
|
529
|
+
* {@link ToSQL}. `ast` is `null` when even the rewritten SQL is unparseable
|
|
530
|
+
* (or when no transform applied — nothing new to try).
|
|
531
|
+
*/
|
|
532
|
+
private static preprocessForParse;
|
|
533
|
+
/**
|
|
534
|
+
* Token-aware scan for a trailing `OPTION (...)` query hint at the
|
|
535
|
+
* outermost level (outside string literals, quoted identifiers, and
|
|
536
|
+
* comments). Returns the SQL without the clause plus the clause text, or
|
|
537
|
+
* `null` when there is no trailing OPTION.
|
|
538
|
+
*/
|
|
539
|
+
private static splitTrailingOption;
|
|
540
|
+
/**
|
|
541
|
+
* Token-aware scan that aliases bracket-quoted identifiers whose interior
|
|
542
|
+
* contains characters node-sql-parser can't handle (`[Active People]`,
|
|
543
|
+
* `[my-cte]`, `[dbo.table]`). Aliases are stable, collision-safe tokens
|
|
544
|
+
* (`_mjid_<seq>`). Applies only to bracket-quoting dialects (SQL Server).
|
|
545
|
+
*
|
|
546
|
+
* Returns the rewritten SQL plus a forward map (original interior → alias).
|
|
547
|
+
*/
|
|
548
|
+
private static readonly BRACKET_ALIAS_PREFIX;
|
|
549
|
+
private static aliasBracketIdentifiers;
|
|
550
|
+
/**
|
|
551
|
+
* Reverses bracket-identifier aliasing on a sqlify result. node-sql-parser
|
|
552
|
+
* may emit the alias bare, bracketed, or backticked; all three forms are
|
|
553
|
+
* restored to the original bracketed identifier. Aliases are unique
|
|
554
|
+
* `BRACKET_ALIAS_PREFIX<seq>` tokens, so replacement is unambiguous.
|
|
555
|
+
*/
|
|
556
|
+
private static restoreAliases;
|
|
557
|
+
/**
|
|
558
|
+
* Advances past a quoted span starting at `start` (whose opening char is
|
|
559
|
+
* `sql[start]`), honoring the doubled-delimiter escape (`''`, `]]`, `""`,
|
|
560
|
+
* `` `` ``). Returns the index just past the closing delimiter.
|
|
561
|
+
*/
|
|
562
|
+
private static skipQuotedFrom;
|
|
333
563
|
/**
|
|
334
564
|
* Detects FOR XML clauses that node-sql-parser can't handle and simplifies them.
|
|
335
565
|
*
|
|
@@ -356,7 +586,7 @@ export declare class SQLParser {
|
|
|
356
586
|
private static extractCTEsViaRegex;
|
|
357
587
|
private static skipWhitespace;
|
|
358
588
|
private static findMatchingCloseParen;
|
|
359
|
-
private static
|
|
589
|
+
private static walkASTForExtraction;
|
|
360
590
|
private static walkFromItem;
|
|
361
591
|
private static walkExpression;
|
|
362
592
|
private static inferTypeFromFilters;
|
package/dist/sql-parser.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sql-parser.d.ts","sourceRoot":"","sources":["../src/sql-parser.ts"],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