@abaplint/core 2.113.82 → 2.113.83
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.
|
@@ -6,7 +6,8 @@ const expressions_1 = require("../expressions");
|
|
|
6
6
|
const version_1 = require("../../../version");
|
|
7
7
|
class Module {
|
|
8
8
|
getMatcher() {
|
|
9
|
-
const
|
|
9
|
+
const sw = (0, combi_1.seq)("SWITCH", expressions_1.NamespaceSimpleName);
|
|
10
|
+
const ret = (0, combi_1.seq)("MODULE", expressions_1.FormName, (0, combi_1.opt)((0, combi_1.alt)("INPUT", "OUTPUT", "ON CHAIN-REQUEST", "ON CHAIN-INPUT", sw)));
|
|
10
11
|
return (0, combi_1.verNot)(version_1.Version.Cloud, ret);
|
|
11
12
|
}
|
|
12
13
|
}
|
|
@@ -85,10 +85,55 @@ class Select {
|
|
|
85
85
|
for (const s of node.findDirectExpressions(Expressions.SQLOrderBy)) {
|
|
86
86
|
new sql_order_by_1.SQLOrderBy().runSyntax(s, input);
|
|
87
87
|
}
|
|
88
|
+
if (this.isStrictMode(node)) {
|
|
89
|
+
this.strictModeChecks(node, input);
|
|
90
|
+
}
|
|
88
91
|
if (input.scope.getType() === _scope_type_1.ScopeType.OpenSQL) {
|
|
89
92
|
input.scope.pop(node.getLastToken().getEnd());
|
|
90
93
|
}
|
|
91
94
|
}
|
|
95
|
+
// there are multiple rules, but gotta start somewhere
|
|
96
|
+
isStrictMode(node) {
|
|
97
|
+
const into = node.findDirectExpressionsMulti([Expressions.SQLIntoList, Expressions.SQLIntoStructure, Expressions.SQLIntoTable])[0];
|
|
98
|
+
const where = node.findDirectExpression(Expressions.SQLCond);
|
|
99
|
+
// INTO is after WHERE
|
|
100
|
+
if (into && where && into.getFirstToken().getStart().isAfter(where.getFirstToken().getStart())) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
// FIELDS is used
|
|
104
|
+
if (node.findFirstExpression(Expressions.SQLFields)) {
|
|
105
|
+
return true;
|
|
106
|
+
}
|
|
107
|
+
// any field is escaped with @
|
|
108
|
+
for (const source of node.findAllExpressions(Expressions.SQLSource)) {
|
|
109
|
+
if (source.getFirstToken().getStr() === "@") {
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// comma used in FROM
|
|
114
|
+
const fieldList = node.findFirstExpression(Expressions.SQLFieldList);
|
|
115
|
+
if (fieldList && fieldList.findDirectTokenByText(",")) {
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
return false;
|
|
119
|
+
}
|
|
120
|
+
strictModeChecks(node, input) {
|
|
121
|
+
const sources = node.findAllExpressions(Expressions.SQLSource);
|
|
122
|
+
for (const source of sources) {
|
|
123
|
+
const first = source.getFirstChild();
|
|
124
|
+
if ((first === null || first === void 0 ? void 0 : first.get()) instanceof Expressions.SQLAliasField) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
else if ((first === null || first === void 0 ? void 0 : first.getFirstToken().getStr()) === "@") {
|
|
128
|
+
continue;
|
|
129
|
+
}
|
|
130
|
+
else if ((first === null || first === void 0 ? void 0 : first.getChildren()[0].get()) instanceof Expressions.Constant) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const message = `SELECT: "${source.concatTokens()}" must be escaped with @ in strict mode`;
|
|
134
|
+
input.issues.push((0, _syntax_input_1.syntaxIssue)(input, node.getFirstToken(), message));
|
|
135
|
+
}
|
|
136
|
+
}
|
|
92
137
|
handleInto(node, input, fields, dbSources) {
|
|
93
138
|
const intoTable = node.findDirectExpression(Expressions.SQLIntoTable);
|
|
94
139
|
if (intoTable) {
|
|
@@ -5,6 +5,7 @@ const Expressions = require("../../2_statements/expressions");
|
|
|
5
5
|
const select_1 = require("../expressions/select");
|
|
6
6
|
class Select {
|
|
7
7
|
runSyntax(node, input) {
|
|
8
|
+
// for UNION statements there are multiple select parts
|
|
8
9
|
const selects = node.findDirectExpressions(Expressions.Select);
|
|
9
10
|
for (let i = 0; i < selects.length; i++) {
|
|
10
11
|
const last = i === selects.length - 1;
|
package/build/src/registry.js
CHANGED
|
@@ -403,6 +403,10 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
403
403
|
if (found) {
|
|
404
404
|
return found;
|
|
405
405
|
}
|
|
406
|
+
found = this.downportSQLMoveInto(low, high, lowFile, highSyntax);
|
|
407
|
+
if (found) {
|
|
408
|
+
return found;
|
|
409
|
+
}
|
|
406
410
|
found = this.downportSQLExtras(low, high, lowFile, highSyntax);
|
|
407
411
|
if (found) {
|
|
408
412
|
return found;
|
|
@@ -536,6 +540,37 @@ Make sure to test the downported code, it might not always be completely correct
|
|
|
536
540
|
return undefined;
|
|
537
541
|
}
|
|
538
542
|
//////////////////////////////////////////
|
|
543
|
+
/** move INTO from after WHERE to after FROM */
|
|
544
|
+
downportSQLMoveInto(low, high, lowFile, _highSyntax) {
|
|
545
|
+
if (!(low.get() instanceof _statement_1.Unknown)) {
|
|
546
|
+
return undefined;
|
|
547
|
+
}
|
|
548
|
+
const where = high.findFirstExpression(Expressions.SQLCond);
|
|
549
|
+
if (where === undefined) {
|
|
550
|
+
return undefined;
|
|
551
|
+
}
|
|
552
|
+
let into = high.findFirstExpression(Expressions.SQLIntoList);
|
|
553
|
+
if (into === undefined) {
|
|
554
|
+
into = high.findFirstExpression(Expressions.SQLIntoStructure);
|
|
555
|
+
}
|
|
556
|
+
if (into === undefined) {
|
|
557
|
+
into = high.findFirstExpression(Expressions.SQLIntoTable);
|
|
558
|
+
}
|
|
559
|
+
if (into === undefined) {
|
|
560
|
+
return undefined;
|
|
561
|
+
}
|
|
562
|
+
if (where.getLastToken().getEnd().isBefore(into.getFirstToken().getStart()) === false) {
|
|
563
|
+
return undefined;
|
|
564
|
+
}
|
|
565
|
+
const from = high.findFirstExpression(Expressions.SQLFrom);
|
|
566
|
+
if (from === undefined) {
|
|
567
|
+
return undefined;
|
|
568
|
+
}
|
|
569
|
+
const fix1 = edit_helper_1.EditHelper.insertAt(lowFile, from.getLastToken().getEnd(), ` ` + into.concatTokens());
|
|
570
|
+
const fix2 = edit_helper_1.EditHelper.deleteRange(lowFile, into.getFirstToken().getStart(), into.getLastToken().getEnd());
|
|
571
|
+
const fix = edit_helper_1.EditHelper.merge(fix2, fix1);
|
|
572
|
+
return issue_1.Issue.atToken(lowFile, low.getFirstToken(), "SQL, move INTO", this.getMetadata().key, this.conf.severity, fix);
|
|
573
|
+
}
|
|
539
574
|
/** removes @'s and commas */
|
|
540
575
|
downportSQLExtras(low, high, lowFile, highSyntax) {
|
|
541
576
|
if (!(low.get() instanceof _statement_1.Unknown)) {
|