@abaplint/transpiler 2.13.29 → 2.13.31
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/build/src/expressions/sql_cond.d.ts +2 -0
- package/build/src/expressions/sql_cond.js +62 -7
- package/build/src/expressions/type_name_or_infer.js +1 -1
- package/build/src/statements/index.d.ts +2 -0
- package/build/src/statements/index.js +2 -0
- package/build/src/statements/modify_entities.d.ts +7 -0
- package/build/src/statements/modify_entities.js +11 -0
- package/build/src/statements/read_entities.d.ts +7 -0
- package/build/src/statements/read_entities.js +11 -0
- package/build/src/structures/select.js +2 -1
- package/build/src/validation.js +1 -0
- package/package.json +3 -3
|
@@ -135,13 +135,7 @@ class SQLCondTranspiler {
|
|
|
135
135
|
if (fieldName === undefined || operator === undefined || source === undefined) {
|
|
136
136
|
throw new Error("SQL Condition, transpiler todo2, " + c.concatTokens());
|
|
137
137
|
}
|
|
138
|
-
|
|
139
|
-
if (op.toUpperCase() === "EQ") {
|
|
140
|
-
op = "=";
|
|
141
|
-
}
|
|
142
|
-
else if (op.toUpperCase() === "NE") {
|
|
143
|
-
op = "<>";
|
|
144
|
-
}
|
|
138
|
+
const op = this.sqlOperator(operator.concatTokens());
|
|
145
139
|
ret += fieldName + " " + op + " ";
|
|
146
140
|
ret += this.sqlSource(source, traversal, filename, table);
|
|
147
141
|
return ret;
|
|
@@ -187,6 +181,10 @@ class SQLCondTranspiler {
|
|
|
187
181
|
return ret;
|
|
188
182
|
}
|
|
189
183
|
basicConditionNew(node, traversal, filename, table) {
|
|
184
|
+
const sourceWithComponents = this.sourceWithComponents(node, traversal);
|
|
185
|
+
if (sourceWithComponents) {
|
|
186
|
+
return sourceWithComponents;
|
|
187
|
+
}
|
|
190
188
|
let ret = "";
|
|
191
189
|
for (const child of node.getChildren()) {
|
|
192
190
|
if (ret !== "") {
|
|
@@ -200,12 +198,69 @@ class SQLCondTranspiler {
|
|
|
200
198
|
&& child instanceof abaplint.Nodes.ExpressionNode) {
|
|
201
199
|
ret += this.sqlSource(child, traversal, filename, table);
|
|
202
200
|
}
|
|
201
|
+
else if (child.get() instanceof abaplint.Expressions.SQLCompareOperator
|
|
202
|
+
&& child instanceof abaplint.Nodes.ExpressionNode) {
|
|
203
|
+
ret += this.sqlOperator(child.concatTokens());
|
|
204
|
+
}
|
|
203
205
|
else {
|
|
204
206
|
ret += child.concatTokens();
|
|
205
207
|
}
|
|
206
208
|
}
|
|
207
209
|
return ret;
|
|
208
210
|
}
|
|
211
|
+
sourceWithComponents(node, traversal) {
|
|
212
|
+
const children = node.getChildren();
|
|
213
|
+
const fieldName = children[0];
|
|
214
|
+
const operator = children[1];
|
|
215
|
+
const source = children[2];
|
|
216
|
+
if (!(fieldName instanceof abaplint.Nodes.ExpressionNode)
|
|
217
|
+
|| !(fieldName.get() instanceof abaplint.Expressions.SQLFieldName)
|
|
218
|
+
|| !(operator instanceof abaplint.Nodes.ExpressionNode)
|
|
219
|
+
|| !(operator.get() instanceof abaplint.Expressions.SQLCompareOperator)
|
|
220
|
+
|| !(source instanceof abaplint.Nodes.ExpressionNode)
|
|
221
|
+
|| !(source.get() instanceof abaplint.Expressions.SQLSource)
|
|
222
|
+
|| children.length < 5
|
|
223
|
+
|| (children.length - 3) % 2 !== 0) {
|
|
224
|
+
return undefined;
|
|
225
|
+
}
|
|
226
|
+
const components = [];
|
|
227
|
+
for (let i = 3; i < children.length; i += 2) {
|
|
228
|
+
const dash = children[i];
|
|
229
|
+
const component = children[i + 1];
|
|
230
|
+
if (!(dash instanceof abaplint.Nodes.TokenNode)
|
|
231
|
+
|| dash.getFirstToken().getStr() !== "-"
|
|
232
|
+
|| !(component instanceof abaplint.Nodes.ExpressionNode)
|
|
233
|
+
|| !(component.get() instanceof abaplint.Expressions.SQLFieldName)) {
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
components.push(component.concatTokens().toLowerCase());
|
|
237
|
+
}
|
|
238
|
+
const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
|
|
239
|
+
if (simple === undefined || simple.findDirectExpression(abaplint.Expressions.Constant)) {
|
|
240
|
+
return undefined;
|
|
241
|
+
}
|
|
242
|
+
let code = new simple_source3_1.SimpleSource3Transpiler(false).transpile(simple, traversal).getCode();
|
|
243
|
+
for (const component of components) {
|
|
244
|
+
if (component.match(/^\d/) || component.includes("/")) {
|
|
245
|
+
code += `.get()["${component}"]`;
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
code += `.get().${component}`;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
code += ".get()";
|
|
252
|
+
const field = new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
|
|
253
|
+
return `${field} ${this.sqlOperator(operator.concatTokens())} '" + ${code} + "'`;
|
|
254
|
+
}
|
|
255
|
+
sqlOperator(op) {
|
|
256
|
+
if (op.toUpperCase() === "EQ") {
|
|
257
|
+
return "=";
|
|
258
|
+
}
|
|
259
|
+
else if (op.toUpperCase() === "NE") {
|
|
260
|
+
return "<>";
|
|
261
|
+
}
|
|
262
|
+
return op;
|
|
263
|
+
}
|
|
209
264
|
}
|
|
210
265
|
exports.SQLCondTranspiler = SQLCondTranspiler;
|
|
211
266
|
//# sourceMappingURL=sql_cond.js.map
|
|
@@ -14,7 +14,7 @@ class TypeNameOrInfer {
|
|
|
14
14
|
return sqlType;
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
-
throw new Error("TypeNameOrInfer, type not found: " + node.concatTokens() + ", " + traversal.getCurrentObject().getName() + " line " + node.getFirstToken().getStart().getRow());
|
|
17
|
+
throw new Error("TypeNameOrInfer, type not found: " + node.concatTokens() + ", " + traversal.getCurrentObject().getName() + ", " + traversal.getFilename() + " line " + node.getFirstToken().getStart().getRow());
|
|
18
18
|
}
|
|
19
19
|
return type;
|
|
20
20
|
}
|
|
@@ -91,6 +91,7 @@ export * from "./macro_call";
|
|
|
91
91
|
export * from "./message";
|
|
92
92
|
export * from "./method_implementation";
|
|
93
93
|
export * from "./modify_database";
|
|
94
|
+
export * from "./modify_entities";
|
|
94
95
|
export * from "./modify_internal";
|
|
95
96
|
export * from "./modify_screen";
|
|
96
97
|
export * from "./move_corresponding";
|
|
@@ -105,6 +106,7 @@ export * from "./raise_event";
|
|
|
105
106
|
export * from "./raise";
|
|
106
107
|
export * from "./ranges";
|
|
107
108
|
export * from "./read_dataset";
|
|
109
|
+
export * from "./read_entities";
|
|
108
110
|
export * from "./read_line";
|
|
109
111
|
export * from "./read_report";
|
|
110
112
|
export * from "./read_table";
|
|
@@ -107,6 +107,7 @@ __exportStar(require("./macro_call"), exports);
|
|
|
107
107
|
__exportStar(require("./message"), exports);
|
|
108
108
|
__exportStar(require("./method_implementation"), exports);
|
|
109
109
|
__exportStar(require("./modify_database"), exports);
|
|
110
|
+
__exportStar(require("./modify_entities"), exports);
|
|
110
111
|
__exportStar(require("./modify_internal"), exports);
|
|
111
112
|
__exportStar(require("./modify_screen"), exports);
|
|
112
113
|
__exportStar(require("./move_corresponding"), exports);
|
|
@@ -121,6 +122,7 @@ __exportStar(require("./raise_event"), exports);
|
|
|
121
122
|
__exportStar(require("./raise"), exports);
|
|
122
123
|
__exportStar(require("./ranges"), exports);
|
|
123
124
|
__exportStar(require("./read_dataset"), exports);
|
|
125
|
+
__exportStar(require("./read_entities"), exports);
|
|
124
126
|
__exportStar(require("./read_line"), exports);
|
|
125
127
|
__exportStar(require("./read_report"), exports);
|
|
126
128
|
__exportStar(require("./read_table"), exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStatementTranspiler } from "./_statement_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class ModifyEntitiesTranspiler implements IStatementTranspiler {
|
|
6
|
+
transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ModifyEntitiesTranspiler = void 0;
|
|
4
|
+
const chunk_1 = require("../chunk");
|
|
5
|
+
class ModifyEntitiesTranspiler {
|
|
6
|
+
transpile(_node, _traversal) {
|
|
7
|
+
return new chunk_1.Chunk(`throw new Error("ModifyEntities, not supported, transpiler");`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ModifyEntitiesTranspiler = ModifyEntitiesTranspiler;
|
|
11
|
+
//# sourceMappingURL=modify_entities.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import * as abaplint from "@abaplint/core";
|
|
2
|
+
import { IStatementTranspiler } from "./_statement_transpiler";
|
|
3
|
+
import { Traversal } from "../traversal";
|
|
4
|
+
import { Chunk } from "../chunk";
|
|
5
|
+
export declare class ReadEntitiesTranspiler implements IStatementTranspiler {
|
|
6
|
+
transpile(_node: abaplint.Nodes.StatementNode, _traversal: Traversal): Chunk;
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReadEntitiesTranspiler = void 0;
|
|
4
|
+
const chunk_1 = require("../chunk");
|
|
5
|
+
class ReadEntitiesTranspiler {
|
|
6
|
+
transpile(_node, _traversal) {
|
|
7
|
+
return new chunk_1.Chunk(`throw new Error("ReadEntities, not supported, transpiler");`);
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.ReadEntitiesTranspiler = ReadEntitiesTranspiler;
|
|
11
|
+
//# sourceMappingURL=read_entities.js.map
|
|
@@ -62,7 +62,8 @@ class SelectTranspiler {
|
|
|
62
62
|
ret.appendString(`let ${targetName} = new abap.types.Table(abap.DDIC["${from}"].type());\n`);
|
|
63
63
|
ret.appendChunk(new select_1.SelectTranspiler().transpile(selectStatement, traversal, targetName));
|
|
64
64
|
// todo: optimize, it should do real streaming?
|
|
65
|
-
const packageSize =
|
|
65
|
+
const packageSize = selectStatement.findFirstExpression(abaplint.Expressions.SQLPackageSize)
|
|
66
|
+
?.findFirstExpression(abaplint.Expressions.SQLSource);
|
|
66
67
|
if (packageSize) {
|
|
67
68
|
const getSize = new expressions_1.SQLSourceTranspiler().transpile(packageSize, traversal).getCode() + ".get()";
|
|
68
69
|
ret.appendString(`if (${targetName}.array().length > ${getSize}) {
|
package/build/src/validation.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.31",
|
|
4
4
|
"description": "Transpiler",
|
|
5
5
|
"main": "build/src/index.js",
|
|
6
6
|
"typings": "build/src/index.d.ts",
|
|
@@ -29,14 +29,14 @@
|
|
|
29
29
|
"author": "abaplint",
|
|
30
30
|
"license": "MIT",
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@abaplint/core": "^2.119.
|
|
32
|
+
"@abaplint/core": "^2.119.31",
|
|
33
33
|
"source-map": "^0.7.6"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
36
|
"@types/chai": "^4.3.20",
|
|
37
37
|
"@types/mocha": "^10.0.10",
|
|
38
38
|
"chai": "^4.5.0",
|
|
39
|
-
"mocha": "^11.7.
|
|
39
|
+
"mocha": "^11.7.6",
|
|
40
40
|
"source-map-support": "^0.5.21",
|
|
41
41
|
"typescript": "^6.0.3"
|
|
42
42
|
}
|