rawsql-ts 0.1.0-beta.4 → 0.1.0-beta.6
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/README.md +143 -199
- package/dist/index.js +32 -0
- package/dist/index.js.map +1 -0
- package/dist/models/BinarySelectQuery.js +140 -0
- package/dist/models/BinarySelectQuery.js.map +1 -0
- package/dist/models/Clause.js +318 -0
- package/dist/models/Clause.js.map +1 -0
- package/dist/models/KeywordTrie.js +52 -0
- package/dist/models/KeywordTrie.js.map +1 -0
- package/dist/models/Lexeme.js +21 -0
- package/dist/models/Lexeme.js.map +1 -0
- package/dist/models/SelectQuery.js +10 -0
- package/dist/models/SelectQuery.js.map +1 -0
- package/dist/models/SimpleSelectQuery.js +290 -0
- package/dist/models/SimpleSelectQuery.js.map +1 -0
- package/dist/models/SqlComponent.js +27 -0
- package/dist/models/SqlComponent.js.map +1 -0
- package/dist/models/ValueComponent.js +250 -0
- package/dist/models/ValueComponent.js.map +1 -0
- package/dist/models/ValuesQuery.js +16 -0
- package/dist/models/ValuesQuery.js.map +1 -0
- package/dist/parsers/CommandExpressionParser.js +124 -0
- package/dist/parsers/CommandExpressionParser.js.map +1 -0
- package/dist/parsers/CommonTableParser.js +60 -0
- package/dist/parsers/CommonTableParser.js.map +1 -0
- package/dist/parsers/ForClauseParser.js +56 -0
- package/dist/parsers/ForClauseParser.js.map +1 -0
- package/dist/parsers/FromClauseParser.js +45 -0
- package/dist/parsers/FromClauseParser.js.map +1 -0
- package/dist/parsers/FunctionExpressionParser.js +178 -0
- package/dist/parsers/FunctionExpressionParser.js.map +1 -0
- package/dist/parsers/GroupByParser.js +56 -0
- package/dist/parsers/GroupByParser.js.map +1 -0
- package/dist/parsers/HavingParser.js +34 -0
- package/dist/parsers/HavingParser.js.map +1 -0
- package/dist/parsers/IdentifierParser.js +39 -0
- package/dist/parsers/IdentifierParser.js.map +1 -0
- package/dist/parsers/JoinClauseParser.js +105 -0
- package/dist/parsers/JoinClauseParser.js.map +1 -0
- package/dist/parsers/KeywordParser.js +91 -0
- package/dist/parsers/KeywordParser.js.map +1 -0
- package/dist/parsers/LimitClauseParser.js +48 -0
- package/dist/parsers/LimitClauseParser.js.map +1 -0
- package/dist/parsers/LiteralParser.js +38 -0
- package/dist/parsers/LiteralParser.js.map +1 -0
- package/dist/parsers/OrderByClauseParser.js +75 -0
- package/dist/parsers/OrderByClauseParser.js.map +1 -0
- package/dist/parsers/OverExpressionParser.js +44 -0
- package/dist/parsers/OverExpressionParser.js.map +1 -0
- package/dist/parsers/ParameterExpressionParser.js +15 -0
- package/dist/parsers/ParameterExpressionParser.js.map +1 -0
- package/dist/parsers/ParenExpressionParser.js +33 -0
- package/dist/parsers/ParenExpressionParser.js.map +1 -0
- package/dist/parsers/PartitionByParser.js +51 -0
- package/dist/parsers/PartitionByParser.js.map +1 -0
- package/dist/parsers/SelectClauseParser.js +82 -0
- package/dist/parsers/SelectClauseParser.js.map +1 -0
- package/dist/parsers/SelectQueryParser.js +151 -0
- package/dist/parsers/SelectQueryParser.js.map +1 -0
- package/dist/parsers/SourceAliasExpressionParser.js +48 -0
- package/dist/parsers/SourceAliasExpressionParser.js.map +1 -0
- package/dist/parsers/SourceExpressionParser.js +34 -0
- package/dist/parsers/SourceExpressionParser.js.map +1 -0
- package/dist/parsers/SourceParser.js +116 -0
- package/dist/parsers/SourceParser.js.map +1 -0
- package/dist/parsers/SqlTokenizer.js +174 -0
- package/dist/parsers/SqlTokenizer.js.map +1 -0
- package/dist/parsers/StringSpecifierExpressionParser.js +22 -0
- package/dist/parsers/StringSpecifierExpressionParser.js.map +1 -0
- package/dist/parsers/UnaryExpressionParser.js +30 -0
- package/dist/parsers/UnaryExpressionParser.js.map +1 -0
- package/dist/parsers/ValueParser.js +134 -0
- package/dist/parsers/ValueParser.js.map +1 -0
- package/dist/parsers/ValuesQueryParser.js +86 -0
- package/dist/parsers/ValuesQueryParser.js.map +1 -0
- package/dist/parsers/WhereClauseParser.js +34 -0
- package/dist/parsers/WhereClauseParser.js.map +1 -0
- package/dist/parsers/WindowClauseParser.js +43 -0
- package/dist/parsers/WindowClauseParser.js.map +1 -0
- package/dist/parsers/WindowExpressionParser.js +151 -0
- package/dist/parsers/WindowExpressionParser.js.map +1 -0
- package/dist/parsers/WithClauseParser.js +55 -0
- package/dist/parsers/WithClauseParser.js.map +1 -0
- package/dist/tokenReaders/BaseTokenReader.js +82 -0
- package/dist/tokenReaders/BaseTokenReader.js.map +1 -0
- package/dist/tokenReaders/CommandTokenReader.js +145 -0
- package/dist/tokenReaders/CommandTokenReader.js.map +1 -0
- package/dist/tokenReaders/FunctionTokenReader.js +45 -0
- package/dist/tokenReaders/FunctionTokenReader.js.map +1 -0
- package/dist/tokenReaders/IdentifierTokenReader.js +70 -0
- package/dist/tokenReaders/IdentifierTokenReader.js.map +1 -0
- package/dist/tokenReaders/LiteralTokenReader.js +189 -0
- package/dist/tokenReaders/LiteralTokenReader.js.map +1 -0
- package/dist/tokenReaders/OperatorTokenReader.js +98 -0
- package/dist/tokenReaders/OperatorTokenReader.js.map +1 -0
- package/dist/tokenReaders/ParameterTokenReader.js +44 -0
- package/dist/tokenReaders/ParameterTokenReader.js.map +1 -0
- package/dist/tokenReaders/StringSpecifierTokenReader.js +31 -0
- package/dist/tokenReaders/StringSpecifierTokenReader.js.map +1 -0
- package/dist/tokenReaders/SymbolTokenReader.js +35 -0
- package/dist/tokenReaders/SymbolTokenReader.js.map +1 -0
- package/dist/tokenReaders/TokenReaderManager.js +110 -0
- package/dist/tokenReaders/TokenReaderManager.js.map +1 -0
- package/dist/tokenReaders/TypeTokenReader.js +59 -0
- package/dist/tokenReaders/TypeTokenReader.js.map +1 -0
- package/dist/transformers/CTEBuilder.js +188 -0
- package/dist/transformers/CTEBuilder.js.map +1 -0
- package/dist/transformers/CTECollector.js +384 -0
- package/dist/transformers/CTECollector.js.map +1 -0
- package/dist/transformers/CTEDisabler.js +325 -0
- package/dist/transformers/CTEDisabler.js.map +1 -0
- package/dist/transformers/CTEInjector.js +83 -0
- package/dist/transformers/CTEInjector.js.map +1 -0
- package/dist/transformers/CTENormalizer.js +42 -0
- package/dist/transformers/CTENormalizer.js.map +1 -0
- package/dist/transformers/Formatter.js +452 -0
- package/dist/transformers/Formatter.js.map +1 -0
- package/dist/transformers/QueryNormalizer.js +114 -0
- package/dist/transformers/QueryNormalizer.js.map +1 -0
- package/dist/transformers/SelectValueCollector.js +249 -0
- package/dist/transformers/SelectValueCollector.js.map +1 -0
- package/dist/transformers/SelectableColumnCollector.js +308 -0
- package/dist/transformers/SelectableColumnCollector.js.map +1 -0
- package/dist/transformers/TableSourceCollector.js +384 -0
- package/dist/transformers/TableSourceCollector.js.map +1 -0
- package/dist/transformers/UpstreamSelectQueryFinder.js +129 -0
- package/dist/transformers/UpstreamSelectQueryFinder.js.map +1 -0
- package/dist/utils/charLookupTable.js +73 -0
- package/dist/utils/charLookupTable.js.map +1 -0
- package/dist/utils/stringUtils.js +168 -0
- package/dist/utils/stringUtils.js.map +1 -0
- package/package.json +3 -3
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/vitest.config.js +0 -15
- package/dist/vitest.config.js.map +0 -1
@@ -0,0 +1,290 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SimpleSelectQuery = void 0;
|
4
|
+
const SqlComponent_1 = require("./SqlComponent");
|
5
|
+
const Clause_1 = require("./Clause");
|
6
|
+
const ValueComponent_1 = require("./ValueComponent");
|
7
|
+
const ValueParser_1 = require("../parsers/ValueParser");
|
8
|
+
const CTENormalizer_1 = require("../transformers/CTENormalizer");
|
9
|
+
const SelectableColumnCollector_1 = require("../transformers/SelectableColumnCollector");
|
10
|
+
const SourceParser_1 = require("../parsers/SourceParser");
|
11
|
+
const BinarySelectQuery_1 = require("./BinarySelectQuery");
|
12
|
+
const SelectQueryParser_1 = require("../parsers/SelectQueryParser");
|
13
|
+
/**
|
14
|
+
* Represents a simple SELECT query in SQL.
|
15
|
+
*/
|
16
|
+
class SimpleSelectQuery extends SqlComponent_1.SqlComponent {
|
17
|
+
constructor(withClause, selectClause, fromClause, whereClause, groupByClause, havingClause, orderByClause, windowFrameClause, rowLimitClause, forClause) {
|
18
|
+
super();
|
19
|
+
this.WithClause = null;
|
20
|
+
this.WithClause = withClause;
|
21
|
+
this.selectClause = selectClause;
|
22
|
+
this.fromClause = fromClause;
|
23
|
+
this.whereClause = whereClause;
|
24
|
+
this.groupByClause = groupByClause;
|
25
|
+
this.havingClause = havingClause;
|
26
|
+
this.orderByClause = orderByClause;
|
27
|
+
this.windowFrameClause = windowFrameClause;
|
28
|
+
this.rowLimitClause = rowLimitClause;
|
29
|
+
this.forClause = forClause;
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
33
|
+
* using UNION as the operator.
|
34
|
+
*
|
35
|
+
* @param rightQuery The right side of the UNION
|
36
|
+
* @returns A new BinarySelectQuery representing "this UNION rightQuery"
|
37
|
+
*/
|
38
|
+
toUnion(rightQuery) {
|
39
|
+
return this.toBinaryQuery('union', rightQuery);
|
40
|
+
}
|
41
|
+
/**
|
42
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
43
|
+
* using UNION ALL as the operator.
|
44
|
+
*
|
45
|
+
* @param rightQuery The right side of the UNION ALL
|
46
|
+
* @returns A new BinarySelectQuery representing "this UNION ALL rightQuery"
|
47
|
+
*/
|
48
|
+
toUnionAll(rightQuery) {
|
49
|
+
return this.toBinaryQuery('union all', rightQuery);
|
50
|
+
}
|
51
|
+
/**
|
52
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
53
|
+
* using INTERSECT as the operator.
|
54
|
+
*
|
55
|
+
* @param rightQuery The right side of the INTERSECT
|
56
|
+
* @returns A new BinarySelectQuery representing "this INTERSECT rightQuery"
|
57
|
+
*/
|
58
|
+
toIntersect(rightQuery) {
|
59
|
+
return this.toBinaryQuery('intersect', rightQuery);
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
63
|
+
* using INTERSECT ALL as the operator.
|
64
|
+
*
|
65
|
+
* @param rightQuery The right side of the INTERSECT ALL
|
66
|
+
* @returns A new BinarySelectQuery representing "this INTERSECT ALL rightQuery"
|
67
|
+
*/
|
68
|
+
toIntersectAll(rightQuery) {
|
69
|
+
return this.toBinaryQuery('intersect all', rightQuery);
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
73
|
+
* using EXCEPT as the operator.
|
74
|
+
*
|
75
|
+
* @param rightQuery The right side of the EXCEPT
|
76
|
+
* @returns A new BinarySelectQuery representing "this EXCEPT rightQuery"
|
77
|
+
*/
|
78
|
+
toExcept(rightQuery) {
|
79
|
+
return this.toBinaryQuery('except', rightQuery);
|
80
|
+
}
|
81
|
+
/**
|
82
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
83
|
+
* using EXCEPT ALL as the operator.
|
84
|
+
*
|
85
|
+
* @param rightQuery The right side of the EXCEPT ALL
|
86
|
+
* @returns A new BinarySelectQuery representing "this EXCEPT ALL rightQuery"
|
87
|
+
*/
|
88
|
+
toExceptAll(rightQuery) {
|
89
|
+
return this.toBinaryQuery('except all', rightQuery);
|
90
|
+
}
|
91
|
+
/**
|
92
|
+
* Creates a new BinarySelectQuery with this query as the left side and the provided query as the right side,
|
93
|
+
* using the specified operator.
|
94
|
+
*
|
95
|
+
* @param operator SQL operator to use (e.g. 'union', 'union all', 'intersect', 'except')
|
96
|
+
* @param rightQuery The right side of the binary operation
|
97
|
+
* @returns A new BinarySelectQuery representing "this [operator] rightQuery"
|
98
|
+
*/
|
99
|
+
toBinaryQuery(operator, rightQuery) {
|
100
|
+
return new BinarySelectQuery_1.BinarySelectQuery(this, operator, rightQuery);
|
101
|
+
}
|
102
|
+
/**
|
103
|
+
* Appends a new condition to the query's WHERE clause using AND logic.
|
104
|
+
* The condition is provided as a raw SQL string which is parsed internally.
|
105
|
+
*
|
106
|
+
* @param rawCondition Raw SQL string representing the condition (e.g. "status = 'active'")
|
107
|
+
*/
|
108
|
+
appendWhereRaw(rawCondition) {
|
109
|
+
const parsedCondition = ValueParser_1.ValueParser.parseFromText(rawCondition);
|
110
|
+
this.appendWhere(parsedCondition);
|
111
|
+
}
|
112
|
+
/**
|
113
|
+
* Appends a new condition to the query's WHERE clause using AND logic.
|
114
|
+
* The condition is provided as a ValueComponent object.
|
115
|
+
*
|
116
|
+
* @param condition ValueComponent representing the condition
|
117
|
+
*/
|
118
|
+
appendWhere(condition) {
|
119
|
+
if (!this.whereClause) {
|
120
|
+
this.whereClause = new Clause_1.WhereClause(condition);
|
121
|
+
}
|
122
|
+
else {
|
123
|
+
this.whereClause.condition = new ValueComponent_1.BinaryExpression(this.whereClause.condition, 'and', condition);
|
124
|
+
}
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* Appends a new condition to the query's HAVING clause using AND logic.
|
128
|
+
* The condition is provided as a raw SQL string which is parsed internally.
|
129
|
+
*
|
130
|
+
* @param rawCondition Raw SQL string representing the condition (e.g. "count(*) > 5")
|
131
|
+
*/
|
132
|
+
appendHavingRaw(rawCondition) {
|
133
|
+
const parsedCondition = ValueParser_1.ValueParser.parseFromText(rawCondition);
|
134
|
+
this.appendHaving(parsedCondition);
|
135
|
+
}
|
136
|
+
/**
|
137
|
+
* Appends a new condition to the query's HAVING clause using AND logic.
|
138
|
+
* The condition is provided as a ValueComponent object.
|
139
|
+
*
|
140
|
+
* @param condition ValueComponent representing the condition
|
141
|
+
*/
|
142
|
+
appendHaving(condition) {
|
143
|
+
if (!this.havingClause) {
|
144
|
+
this.havingClause = new Clause_1.HavingClause(condition);
|
145
|
+
}
|
146
|
+
else {
|
147
|
+
this.havingClause.condition = new ValueComponent_1.BinaryExpression(this.havingClause.condition, 'and', condition);
|
148
|
+
}
|
149
|
+
}
|
150
|
+
/**
|
151
|
+
* Appends an INNER JOIN clause to the query.
|
152
|
+
* @param joinSourceRawText The table source text to join (e.g., "my_table", "schema.my_table")
|
153
|
+
* @param alias The alias for the joined table
|
154
|
+
* @param columns The columns to use for the join condition (e.g. ["user_id"])
|
155
|
+
*/
|
156
|
+
innerJoinRaw(joinSourceRawText, alias, columns) {
|
157
|
+
this.joinSourceRaw('inner join', joinSourceRawText, alias, columns);
|
158
|
+
}
|
159
|
+
/**
|
160
|
+
* Appends a LEFT JOIN clause to the query.
|
161
|
+
* @param joinSourceRawText The table source text to join
|
162
|
+
* @param alias The alias for the joined table
|
163
|
+
* @param columns The columns to use for the join condition
|
164
|
+
*/
|
165
|
+
leftJoinRaw(joinSourceRawText, alias, columns) {
|
166
|
+
this.joinSourceRaw('left join', joinSourceRawText, alias, columns);
|
167
|
+
}
|
168
|
+
/**
|
169
|
+
* Appends a RIGHT JOIN clause to the query.
|
170
|
+
* @param joinSourceRawText The table source text to join
|
171
|
+
* @param alias The alias for the joined table
|
172
|
+
* @param columns The columns to use for the join condition
|
173
|
+
*/
|
174
|
+
rightJoinRaw(joinSourceRawText, alias, columns) {
|
175
|
+
this.joinSourceRaw('right join', joinSourceRawText, alias, columns);
|
176
|
+
}
|
177
|
+
/**
|
178
|
+
* Appends an INNER JOIN clause to the query using a SourceExpression.
|
179
|
+
* @param sourceExpr The source expression to join
|
180
|
+
* @param columns The columns to use for the join condition
|
181
|
+
*/
|
182
|
+
innerJoin(sourceExpr, columns) {
|
183
|
+
this.joinSource('inner join', sourceExpr, columns);
|
184
|
+
}
|
185
|
+
/**
|
186
|
+
* Appends a LEFT JOIN clause to the query using a SourceExpression.
|
187
|
+
* @param sourceExpr The source expression to join
|
188
|
+
* @param columns The columns to use for the join condition
|
189
|
+
*/
|
190
|
+
leftJoin(sourceExpr, columns) {
|
191
|
+
this.joinSource('left join', sourceExpr, columns);
|
192
|
+
}
|
193
|
+
/**
|
194
|
+
* Appends a RIGHT JOIN clause to the query using a SourceExpression.
|
195
|
+
* @param sourceExpr The source expression to join
|
196
|
+
* @param columns The columns to use for the join condition
|
197
|
+
*/
|
198
|
+
rightJoin(sourceExpr, columns) {
|
199
|
+
this.joinSource('right join', sourceExpr, columns);
|
200
|
+
}
|
201
|
+
/**
|
202
|
+
* Internal helper to append a JOIN clause.
|
203
|
+
* Parses the table source, finds the corresponding columns in the existing query context,
|
204
|
+
* and builds the JOIN condition.
|
205
|
+
* @param joinType Type of join (e.g., 'inner join', 'left join')
|
206
|
+
* @param joinSourceRawText Raw text for the table/source to join (e.g., "my_table", "schema.another_table")
|
207
|
+
* @param alias Alias for the table/source being joined
|
208
|
+
* @param columns Array of column names to join on
|
209
|
+
*/
|
210
|
+
joinSourceRaw(joinType, joinSourceRawText, alias, columns) {
|
211
|
+
const tableSource = SourceParser_1.SourceParser.parseFromText(joinSourceRawText);
|
212
|
+
const sourceExpr = new Clause_1.SourceExpression(tableSource, new Clause_1.SourceAliasExpression(alias, null));
|
213
|
+
this.joinSource(joinType, sourceExpr, columns);
|
214
|
+
}
|
215
|
+
joinSource(joinType, sourceExpr, columns) {
|
216
|
+
if (!this.fromClause) {
|
217
|
+
throw new Error('A FROM clause is required to add a JOIN condition.');
|
218
|
+
}
|
219
|
+
const collector = new SelectableColumnCollector_1.SelectableColumnCollector();
|
220
|
+
const valueSets = collector.collect(this);
|
221
|
+
let joinCondition = null;
|
222
|
+
let count = 0;
|
223
|
+
const sourceAlias = sourceExpr.getAliasName();
|
224
|
+
if (!sourceAlias) {
|
225
|
+
throw new Error('An alias is required for the source expression to add a JOIN condition.');
|
226
|
+
}
|
227
|
+
for (const valueSet of valueSets) {
|
228
|
+
if (columns.some(col => col == valueSet.name)) {
|
229
|
+
const expr = new ValueComponent_1.BinaryExpression(valueSet.value, '=', new ValueComponent_1.ColumnReference([sourceAlias], valueSet.name));
|
230
|
+
if (joinCondition) {
|
231
|
+
joinCondition = new ValueComponent_1.BinaryExpression(joinCondition, 'and', expr);
|
232
|
+
}
|
233
|
+
else {
|
234
|
+
joinCondition = expr;
|
235
|
+
}
|
236
|
+
count++;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
if (!joinCondition || count !== columns.length) {
|
240
|
+
throw new Error(`Invalid JOIN condition. The specified columns were not found: ${columns.join(', ')}`);
|
241
|
+
}
|
242
|
+
const joinOnClause = new Clause_1.JoinOnClause(joinCondition);
|
243
|
+
const joinClause = new Clause_1.JoinClause(joinType, sourceExpr, joinOnClause, false);
|
244
|
+
if (this.fromClause) {
|
245
|
+
if (this.fromClause.joins) {
|
246
|
+
this.fromClause.joins.push(joinClause);
|
247
|
+
}
|
248
|
+
else {
|
249
|
+
this.fromClause.joins = [joinClause];
|
250
|
+
}
|
251
|
+
}
|
252
|
+
const normalizer = new CTENormalizer_1.CTENormalizer();
|
253
|
+
normalizer.normalize(this);
|
254
|
+
}
|
255
|
+
// Returns a SourceExpression wrapping this query as a subquery source.
|
256
|
+
// Alias is required for correct SQL generation and join logic.
|
257
|
+
toSource(alias) {
|
258
|
+
if (!alias || alias.trim() === "") {
|
259
|
+
throw new Error("Alias is required for toSource(). Please specify a non-empty alias name.");
|
260
|
+
}
|
261
|
+
return new Clause_1.SourceExpression(new Clause_1.SubQuerySource(this), new Clause_1.SourceAliasExpression(alias, null));
|
262
|
+
}
|
263
|
+
appendWith(commonTable) {
|
264
|
+
// Always treat as array for simplicity
|
265
|
+
const tables = Array.isArray(commonTable) ? commonTable : [commonTable];
|
266
|
+
if (!this.WithClause) {
|
267
|
+
this.WithClause = new Clause_1.WithClause(false, tables);
|
268
|
+
}
|
269
|
+
else {
|
270
|
+
this.WithClause.tables.push(...tables);
|
271
|
+
}
|
272
|
+
const normalizer = new CTENormalizer_1.CTENormalizer();
|
273
|
+
normalizer.normalize(this);
|
274
|
+
}
|
275
|
+
/**
|
276
|
+
* Appends a CommonTable (CTE) to the WITH clause from raw SQL text and alias.
|
277
|
+
* If alias is provided, it will be used as the CTE name.
|
278
|
+
*
|
279
|
+
* @param rawText Raw SQL string representing the CTE body (e.g. '(SELECT ...)')
|
280
|
+
* @param alias Optional alias for the CTE (e.g. 'cte_name')
|
281
|
+
*/
|
282
|
+
appendWithRaw(rawText, alias) {
|
283
|
+
const query = SelectQueryParser_1.SelectQueryParser.parseFromText(rawText);
|
284
|
+
const commonTable = new Clause_1.CommonTable(query, alias, null);
|
285
|
+
this.appendWith(commonTable);
|
286
|
+
}
|
287
|
+
}
|
288
|
+
exports.SimpleSelectQuery = SimpleSelectQuery;
|
289
|
+
SimpleSelectQuery.kind = Symbol("SelectQuery");
|
290
|
+
//# sourceMappingURL=SimpleSelectQuery.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SimpleSelectQuery.js","sourceRoot":"","sources":["../../src/models/SimpleSelectQuery.ts"],"names":[],"mappings":";;;AAAA,iDAA8C;AAC9C,qCAAoQ;AACpQ,qDAAqF;AACrF,wDAAqD;AACrD,iEAA8D;AAC9D,yFAAsF;AACtF,0DAAuD;AACvD,2DAAwD;AAGxD,oEAAiE;AAEjE;;GAEG;AACH,MAAa,iBAAkB,SAAQ,2BAAY;IAa/C,YACI,UAA6B,EAC7B,YAA0B,EAC1B,UAA6B,EAC7B,WAA+B,EAC/B,aAAmC,EACnC,YAAiC,EACjC,aAAmC,EACnC,iBAA2C,EAC3C,cAAkC,EAClC,SAA2B;QAE3B,KAAK,EAAE,CAAC;QAvBZ,eAAU,GAAsB,IAAI,CAAC;QAwBjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,iB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L,8CAiVC;AAhVU,sBAAI,GAAG,MAAM,CAAC,aAAa,CAAC,AAAxB,CAAyB"}
|
@@ -0,0 +1,27 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.SqlDialectConfiguration = exports.SqlComponent = void 0;
|
4
|
+
class SqlComponent {
|
5
|
+
constructor() {
|
6
|
+
this.comments = null;
|
7
|
+
}
|
8
|
+
getKind() {
|
9
|
+
return this.constructor.kind;
|
10
|
+
}
|
11
|
+
accept(visitor) {
|
12
|
+
return visitor.visit(this);
|
13
|
+
}
|
14
|
+
toSqlString(formatter) {
|
15
|
+
return this.accept(formatter);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
exports.SqlComponent = SqlComponent;
|
19
|
+
class SqlDialectConfiguration {
|
20
|
+
constructor() {
|
21
|
+
this.parameterSymbol = ":";
|
22
|
+
this.identifierEscape = { start: '"', end: '"' };
|
23
|
+
this.exportComment = true;
|
24
|
+
}
|
25
|
+
}
|
26
|
+
exports.SqlDialectConfiguration = SqlDialectConfiguration;
|
27
|
+
//# sourceMappingURL=SqlComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"SqlComponent.js","sourceRoot":"","sources":["../../src/models/SqlComponent.ts"],"names":[],"mappings":";;;AAAA,MAAsB,YAAY;IAAlC;QAgBI,aAAQ,GAAoB,IAAI,CAAC;IACrC,CAAC;IAbG,OAAO;QACH,OAAQ,IAAI,CAAC,WAAmC,CAAC,IAAI,CAAC;IAC1D,CAAC;IAED,MAAM,CAAI,OAA+B;QACrC,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,WAAW,CAAC,SAAsC;QAC9C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IAClC,CAAC;CAGJ;AAjBD,oCAiBC;AAMD,MAAa,uBAAuB;IAApC;QACW,oBAAe,GAAW,GAAG,CAAC;QAC9B,qBAAgB,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QAC5C,kBAAa,GAAY,IAAI,CAAC;IACzC,CAAC;CAAA;AAJD,0DAIC"}
|
@@ -0,0 +1,250 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.TupleExpression = exports.TypeValue = exports.StringSpecifierExpression = exports.BetweenExpression = exports.ArrayExpression = exports.CaseExpression = exports.CastExpression = exports.ParenExpression = exports.IdentifierString = exports.RawString = exports.CaseKeyValuePair = exports.SwitchCaseArgument = exports.ParameterExpression = exports.LiteralValue = exports.BinaryExpression = exports.UnaryExpression = exports.WindowFrameExpression = exports.WindowFrameSpec = exports.WindowFrameBoundaryValue = exports.WindowFrameBoundStatic = exports.WindowFrameBound = exports.WindowFrameType = exports.FunctionCall = exports.ColumnReference = exports.ValueList = exports.InlineQuery = void 0;
|
4
|
+
const SqlComponent_1 = require("./SqlComponent");
|
5
|
+
class InlineQuery extends SqlComponent_1.SqlComponent {
|
6
|
+
constructor(selectQuery) {
|
7
|
+
super();
|
8
|
+
this.selectQuery = selectQuery;
|
9
|
+
}
|
10
|
+
}
|
11
|
+
exports.InlineQuery = InlineQuery;
|
12
|
+
InlineQuery.kind = Symbol("InlineQuery");
|
13
|
+
class ValueList extends SqlComponent_1.SqlComponent {
|
14
|
+
constructor(values) {
|
15
|
+
super();
|
16
|
+
this.values = values;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
exports.ValueList = ValueList;
|
20
|
+
ValueList.kind = Symbol("ValueList");
|
21
|
+
class ColumnReference extends SqlComponent_1.SqlComponent {
|
22
|
+
constructor(namespaces, column) {
|
23
|
+
super();
|
24
|
+
this.namespaces = namespaces !== null ? namespaces.map((namespace) => new IdentifierString(namespace)) : null;
|
25
|
+
this.column = new IdentifierString(column);
|
26
|
+
}
|
27
|
+
toString() {
|
28
|
+
if (this.namespaces) {
|
29
|
+
return this.getNamespace() + "." + this.column.name;
|
30
|
+
}
|
31
|
+
else {
|
32
|
+
return this.column.name;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
getNamespace() {
|
36
|
+
if (this.namespaces) {
|
37
|
+
return this.namespaces.map((namespace) => namespace.name).join(".");
|
38
|
+
}
|
39
|
+
else {
|
40
|
+
return '';
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
exports.ColumnReference = ColumnReference;
|
45
|
+
ColumnReference.kind = Symbol("ColumnReferenceExpression");
|
46
|
+
class FunctionCall extends SqlComponent_1.SqlComponent {
|
47
|
+
constructor(name, argument, over) {
|
48
|
+
super();
|
49
|
+
this.name = new RawString(name);
|
50
|
+
this.argument = argument;
|
51
|
+
this.over = over;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
exports.FunctionCall = FunctionCall;
|
55
|
+
FunctionCall.kind = Symbol("FunctionCall");
|
56
|
+
var WindowFrameType;
|
57
|
+
(function (WindowFrameType) {
|
58
|
+
WindowFrameType["Rows"] = "rows";
|
59
|
+
WindowFrameType["Range"] = "range";
|
60
|
+
WindowFrameType["Groups"] = "groups";
|
61
|
+
})(WindowFrameType || (exports.WindowFrameType = WindowFrameType = {}));
|
62
|
+
var WindowFrameBound;
|
63
|
+
(function (WindowFrameBound) {
|
64
|
+
WindowFrameBound["UnboundedPreceding"] = "unbounded preceding";
|
65
|
+
WindowFrameBound["UnboundedFollowing"] = "unbounded following";
|
66
|
+
WindowFrameBound["CurrentRow"] = "current row";
|
67
|
+
})(WindowFrameBound || (exports.WindowFrameBound = WindowFrameBound = {}));
|
68
|
+
class WindowFrameBoundStatic extends SqlComponent_1.SqlComponent {
|
69
|
+
constructor(bound) {
|
70
|
+
super();
|
71
|
+
this.bound = bound;
|
72
|
+
}
|
73
|
+
}
|
74
|
+
exports.WindowFrameBoundStatic = WindowFrameBoundStatic;
|
75
|
+
WindowFrameBoundStatic.kind = Symbol("WindowFrameStaticBound");
|
76
|
+
class WindowFrameBoundaryValue extends SqlComponent_1.SqlComponent {
|
77
|
+
constructor(value, isFollowing) {
|
78
|
+
super();
|
79
|
+
this.value = value;
|
80
|
+
this.isFollowing = isFollowing;
|
81
|
+
}
|
82
|
+
}
|
83
|
+
exports.WindowFrameBoundaryValue = WindowFrameBoundaryValue;
|
84
|
+
WindowFrameBoundaryValue.kind = Symbol("WindowFrameBoundary");
|
85
|
+
class WindowFrameSpec extends SqlComponent_1.SqlComponent {
|
86
|
+
constructor(frameType, startBound, endBound) {
|
87
|
+
super();
|
88
|
+
this.frameType = frameType;
|
89
|
+
this.startBound = startBound;
|
90
|
+
this.endBound = endBound;
|
91
|
+
}
|
92
|
+
}
|
93
|
+
exports.WindowFrameSpec = WindowFrameSpec;
|
94
|
+
WindowFrameSpec.kind = Symbol("WindowFrameSpec");
|
95
|
+
class WindowFrameExpression extends SqlComponent_1.SqlComponent {
|
96
|
+
constructor(partition, order, frameSpec = null) {
|
97
|
+
super();
|
98
|
+
this.partition = partition;
|
99
|
+
this.order = order;
|
100
|
+
this.frameSpec = frameSpec;
|
101
|
+
}
|
102
|
+
}
|
103
|
+
exports.WindowFrameExpression = WindowFrameExpression;
|
104
|
+
WindowFrameExpression.kind = Symbol("WindowFrameExpression");
|
105
|
+
class UnaryExpression extends SqlComponent_1.SqlComponent {
|
106
|
+
constructor(operator, expression) {
|
107
|
+
super();
|
108
|
+
this.operator = new RawString(operator);
|
109
|
+
this.expression = expression;
|
110
|
+
}
|
111
|
+
}
|
112
|
+
exports.UnaryExpression = UnaryExpression;
|
113
|
+
UnaryExpression.kind = Symbol("UnaryExpression");
|
114
|
+
class BinaryExpression extends SqlComponent_1.SqlComponent {
|
115
|
+
constructor(left, operator, right) {
|
116
|
+
super();
|
117
|
+
this.left = left;
|
118
|
+
this.operator = new RawString(operator);
|
119
|
+
this.right = right;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
exports.BinaryExpression = BinaryExpression;
|
123
|
+
BinaryExpression.kind = Symbol("BinaryExpression");
|
124
|
+
class LiteralValue extends SqlComponent_1.SqlComponent {
|
125
|
+
constructor(value) {
|
126
|
+
super();
|
127
|
+
this.value = value;
|
128
|
+
}
|
129
|
+
}
|
130
|
+
exports.LiteralValue = LiteralValue;
|
131
|
+
LiteralValue.kind = Symbol("LiteralExpression");
|
132
|
+
class ParameterExpression extends SqlComponent_1.SqlComponent {
|
133
|
+
constructor(name) {
|
134
|
+
super();
|
135
|
+
this.name = new RawString(name);
|
136
|
+
}
|
137
|
+
}
|
138
|
+
exports.ParameterExpression = ParameterExpression;
|
139
|
+
ParameterExpression.kind = Symbol("ParameterExpression");
|
140
|
+
class SwitchCaseArgument extends SqlComponent_1.SqlComponent {
|
141
|
+
constructor(cases, elseValue = null) {
|
142
|
+
super();
|
143
|
+
this.cases = cases;
|
144
|
+
this.elseValue = elseValue;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
exports.SwitchCaseArgument = SwitchCaseArgument;
|
148
|
+
SwitchCaseArgument.kind = Symbol("SwitchCaseArgument");
|
149
|
+
class CaseKeyValuePair extends SqlComponent_1.SqlComponent {
|
150
|
+
constructor(key, value) {
|
151
|
+
super();
|
152
|
+
this.key = key;
|
153
|
+
this.value = value;
|
154
|
+
}
|
155
|
+
}
|
156
|
+
exports.CaseKeyValuePair = CaseKeyValuePair;
|
157
|
+
CaseKeyValuePair.kind = Symbol("CaseKeyValuePair");
|
158
|
+
/*
|
159
|
+
* Values that must be hard-coded, such as type names and function names.
|
160
|
+
* A simple check is performed when decoding.
|
161
|
+
*/
|
162
|
+
class RawString extends SqlComponent_1.SqlComponent {
|
163
|
+
constructor(value) {
|
164
|
+
super();
|
165
|
+
this.value = value;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
exports.RawString = RawString;
|
169
|
+
RawString.kind = Symbol("RawString");
|
170
|
+
class IdentifierString extends SqlComponent_1.SqlComponent {
|
171
|
+
constructor(alias) {
|
172
|
+
super();
|
173
|
+
this.name = alias;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
exports.IdentifierString = IdentifierString;
|
177
|
+
IdentifierString.kind = Symbol("IdentifierString");
|
178
|
+
class ParenExpression extends SqlComponent_1.SqlComponent {
|
179
|
+
constructor(expression) {
|
180
|
+
super();
|
181
|
+
this.expression = expression;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
exports.ParenExpression = ParenExpression;
|
185
|
+
ParenExpression.kind = Symbol("ParenExpression");
|
186
|
+
class CastExpression extends SqlComponent_1.SqlComponent {
|
187
|
+
constructor(input, castType) {
|
188
|
+
super();
|
189
|
+
this.input = input;
|
190
|
+
this.castType = castType;
|
191
|
+
}
|
192
|
+
}
|
193
|
+
exports.CastExpression = CastExpression;
|
194
|
+
CastExpression.kind = Symbol("CastExpression");
|
195
|
+
class CaseExpression extends SqlComponent_1.SqlComponent {
|
196
|
+
constructor(condition, switchCase) {
|
197
|
+
super();
|
198
|
+
this.condition = condition;
|
199
|
+
this.switchCase = switchCase;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
exports.CaseExpression = CaseExpression;
|
203
|
+
CaseExpression.kind = Symbol("CaseExpression");
|
204
|
+
class ArrayExpression extends SqlComponent_1.SqlComponent {
|
205
|
+
constructor(expression) {
|
206
|
+
super();
|
207
|
+
this.expression = expression;
|
208
|
+
}
|
209
|
+
}
|
210
|
+
exports.ArrayExpression = ArrayExpression;
|
211
|
+
ArrayExpression.kind = Symbol("ArrayExpression");
|
212
|
+
class BetweenExpression extends SqlComponent_1.SqlComponent {
|
213
|
+
constructor(expression, lower, upper, negated) {
|
214
|
+
super();
|
215
|
+
this.expression = expression;
|
216
|
+
this.lower = lower;
|
217
|
+
this.upper = upper;
|
218
|
+
this.negated = negated;
|
219
|
+
}
|
220
|
+
}
|
221
|
+
exports.BetweenExpression = BetweenExpression;
|
222
|
+
BetweenExpression.kind = Symbol("BetweenExpression");
|
223
|
+
class StringSpecifierExpression extends SqlComponent_1.SqlComponent {
|
224
|
+
constructor(specifier, value) {
|
225
|
+
super();
|
226
|
+
this.specifier = new RawString(specifier);
|
227
|
+
this.value = new LiteralValue(value);
|
228
|
+
}
|
229
|
+
}
|
230
|
+
exports.StringSpecifierExpression = StringSpecifierExpression;
|
231
|
+
StringSpecifierExpression.kind = Symbol("StringSpecifierExpression");
|
232
|
+
// other
|
233
|
+
class TypeValue extends SqlComponent_1.SqlComponent {
|
234
|
+
constructor(type, argument = null) {
|
235
|
+
super();
|
236
|
+
this.type = new RawString(type);
|
237
|
+
this.argument = argument;
|
238
|
+
}
|
239
|
+
}
|
240
|
+
exports.TypeValue = TypeValue;
|
241
|
+
TypeValue.kind = Symbol("TypeValue");
|
242
|
+
class TupleExpression extends SqlComponent_1.SqlComponent {
|
243
|
+
constructor(values) {
|
244
|
+
super();
|
245
|
+
this.values = values;
|
246
|
+
}
|
247
|
+
}
|
248
|
+
exports.TupleExpression = TupleExpression;
|
249
|
+
TupleExpression.kind = Symbol("TupleExpression");
|
250
|
+
//# sourceMappingURL=ValueComponent.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ValueComponent.js","sourceRoot":"","sources":["../../src/models/ValueComponent.ts"],"names":[],"mappings":";;;AAEA,iDAA8C;AAuB9C,MAAa,WAAY,SAAQ,2BAAY;IAGzC,YAAY,WAAwB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACnC,CAAC;;AANL,kCAOC;AANU,gBAAI,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAQxC,MAAa,SAAU,SAAQ,2BAAY;IAGvC,YAAY,MAAwB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;;AANL,8BAOC;AANU,cAAI,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAQtC,MAAa,eAAgB,SAAQ,2BAAY;IAM7C,YAAY,UAA2B,EAAE,MAAc;QACnD,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,UAAU,GAAG,UAAU,KAAK,IAAI,CAAC,CAA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I,CAAC,CAAC;QAChC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC7B,CAAC;;AARL,8BASC;AARU,cAAI,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AAUtC,MAAa,eAAgB,SAAQ,2BAAY;IAG7C,YAAY,MAAwB;QAChC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;;AANL,0CAOC;AANU,oBAAI,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC"}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.ValuesQuery = void 0;
|
4
|
+
const SqlComponent_1 = require("./SqlComponent");
|
5
|
+
/**
|
6
|
+
* Represents a VALUES query in SQL.
|
7
|
+
*/
|
8
|
+
class ValuesQuery extends SqlComponent_1.SqlComponent {
|
9
|
+
constructor(tuples) {
|
10
|
+
super();
|
11
|
+
this.tuples = tuples;
|
12
|
+
}
|
13
|
+
}
|
14
|
+
exports.ValuesQuery = ValuesQuery;
|
15
|
+
ValuesQuery.kind = Symbol("ValuesQuery");
|
16
|
+
//# sourceMappingURL=ValuesQuery.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"ValuesQuery.js","sourceRoot":"","sources":["../../src/models/ValuesQuery.ts"],"names":[],"mappings":";;;AACA,iDAA8C;AAG9C;;GAEG;AACH,MAAa,WAAY,SAAQ,2BAAY;IAGzC,YAAY,MAAyB;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;;AANL,kCAOC;AANU,gBAAI,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC"}
|