@abaplint/transpiler-cli 2.7.4 → 2.7.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/build/bundle.js +278 -39
- package/package.json +3 -3
package/build/bundle.js
CHANGED
|
@@ -19455,6 +19455,9 @@ class CurrentScope {
|
|
|
19455
19455
|
getVersion() {
|
|
19456
19456
|
return this.reg.getConfig().getVersion();
|
|
19457
19457
|
}
|
|
19458
|
+
getRegistry() {
|
|
19459
|
+
return this.reg;
|
|
19460
|
+
}
|
|
19458
19461
|
addType(type) {
|
|
19459
19462
|
if (type === undefined) {
|
|
19460
19463
|
return;
|
|
@@ -19554,6 +19557,10 @@ class CurrentScope {
|
|
|
19554
19557
|
const position = new _identifier_1.Identifier(usage, filename);
|
|
19555
19558
|
(_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().references.push({ position, resolved: referencing, referenceType: type, extra });
|
|
19556
19559
|
}
|
|
19560
|
+
addSQLConversion(fieldName, message, token) {
|
|
19561
|
+
var _a;
|
|
19562
|
+
(_a = this.current) === null || _a === void 0 ? void 0 : _a.getData().sqlConversion.push({ fieldName, message, token });
|
|
19563
|
+
}
|
|
19557
19564
|
///////////////////////////
|
|
19558
19565
|
findFunctionModule(name) {
|
|
19559
19566
|
if (name === undefined) {
|
|
@@ -22440,7 +22447,7 @@ class DatabaseTable {
|
|
|
22440
22447
|
const name = token.getStr();
|
|
22441
22448
|
if (name === "(") {
|
|
22442
22449
|
// dynamic
|
|
22443
|
-
return;
|
|
22450
|
+
return undefined;
|
|
22444
22451
|
}
|
|
22445
22452
|
const found = scope.getDDIC().lookupTableOrView2(name);
|
|
22446
22453
|
if (found === undefined && scope.getDDIC().inErrorNamespace(name) === true) {
|
|
@@ -22453,6 +22460,7 @@ class DatabaseTable {
|
|
|
22453
22460
|
scope.addReference(token, found.getIdentifier(), _reference_1.ReferenceType.TableReference, filename);
|
|
22454
22461
|
scope.getDDICReferences().addUsing(scope.getParentObj(), { object: found, token: token, filename: filename });
|
|
22455
22462
|
}
|
|
22463
|
+
return found;
|
|
22456
22464
|
}
|
|
22457
22465
|
}
|
|
22458
22466
|
exports.DatabaseTable = DatabaseTable;
|
|
@@ -24337,17 +24345,16 @@ const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@ab
|
|
|
24337
24345
|
const inline_data_1 = __webpack_require__(/*! ./inline_data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/inline_data.js");
|
|
24338
24346
|
const target_1 = __webpack_require__(/*! ./target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
|
|
24339
24347
|
const sql_from_1 = __webpack_require__(/*! ./sql_from */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_from.js");
|
|
24340
|
-
const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
|
|
24341
24348
|
const sql_for_all_entries_1 = __webpack_require__(/*! ./sql_for_all_entries */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_for_all_entries.js");
|
|
24342
24349
|
const _scope_type_1 = __webpack_require__(/*! ../_scope_type */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/_scope_type.js");
|
|
24350
|
+
const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js");
|
|
24351
|
+
const sql_compare_1 = __webpack_require__(/*! ./sql_compare */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js");
|
|
24343
24352
|
class Select {
|
|
24344
24353
|
runSyntax(node, scope, filename, skipImplicitInto = false) {
|
|
24345
24354
|
var _a, _b;
|
|
24346
24355
|
const token = node.getFirstToken();
|
|
24347
24356
|
const from = node.findDirectExpression(Expressions.SQLFrom);
|
|
24348
|
-
|
|
24349
|
-
new sql_from_1.SQLFrom().runSyntax(from, scope, filename);
|
|
24350
|
-
}
|
|
24357
|
+
const dbSources = from ? new sql_from_1.SQLFrom().runSyntax(from, scope, filename) : [];
|
|
24351
24358
|
for (const inline of node.findAllExpressions(Expressions.InlineData)) {
|
|
24352
24359
|
// todo, for now these are voided
|
|
24353
24360
|
new inline_data_1.InlineData().runSyntax(inline, scope, filename, new basic_1.VoidType("SELECT_todo"));
|
|
@@ -24373,11 +24380,22 @@ class Select {
|
|
|
24373
24380
|
}
|
|
24374
24381
|
}
|
|
24375
24382
|
}
|
|
24376
|
-
|
|
24377
|
-
|
|
24383
|
+
// OFFSET
|
|
24384
|
+
for (const s of node.findDirectExpressions(Expressions.SQLSource)) {
|
|
24385
|
+
new sql_source_1.SQLSource().runSyntax(s, scope, filename);
|
|
24378
24386
|
}
|
|
24379
|
-
for (const
|
|
24380
|
-
|
|
24387
|
+
for (const up of node.findDirectExpressions(Expressions.SQLUpTo)) {
|
|
24388
|
+
for (const s of up.findDirectExpressions(Expressions.SQLSource)) {
|
|
24389
|
+
new sql_source_1.SQLSource().runSyntax(s, scope, filename);
|
|
24390
|
+
}
|
|
24391
|
+
}
|
|
24392
|
+
for (const fae of node.findDirectExpressions(Expressions.SQLForAllEntries)) {
|
|
24393
|
+
for (const s of fae.findDirectExpressions(Expressions.SQLSource)) {
|
|
24394
|
+
new sql_source_1.SQLSource().runSyntax(s, scope, filename);
|
|
24395
|
+
}
|
|
24396
|
+
}
|
|
24397
|
+
for (const s of node.findAllExpressions(Expressions.SQLCompare)) {
|
|
24398
|
+
new sql_compare_1.SQLCompare().runSyntax(s, scope, filename, dbSources);
|
|
24381
24399
|
}
|
|
24382
24400
|
if (scope.getType() === _scope_type_1.ScopeType.OpenSQL) {
|
|
24383
24401
|
scope.pop(node.getLastToken().getEnd());
|
|
@@ -24737,6 +24755,79 @@ exports.SourceFieldSymbol = SourceFieldSymbol;
|
|
|
24737
24755
|
|
|
24738
24756
|
/***/ }),
|
|
24739
24757
|
|
|
24758
|
+
/***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js":
|
|
24759
|
+
/*!****************************************************************************************!*\
|
|
24760
|
+
!*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_compare.js ***!
|
|
24761
|
+
\****************************************************************************************/
|
|
24762
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
24763
|
+
|
|
24764
|
+
"use strict";
|
|
24765
|
+
|
|
24766
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24767
|
+
exports.SQLCompare = void 0;
|
|
24768
|
+
const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
|
|
24769
|
+
const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
|
|
24770
|
+
const sql_source_1 = __webpack_require__(/*! ./sql_source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js");
|
|
24771
|
+
class SQLCompare {
|
|
24772
|
+
runSyntax(node, scope, filename, tables) {
|
|
24773
|
+
var _a;
|
|
24774
|
+
let sourceType;
|
|
24775
|
+
let token;
|
|
24776
|
+
for (const s of node.findAllExpressions(Expressions.SQLSource)) {
|
|
24777
|
+
token = s.getFirstToken();
|
|
24778
|
+
sourceType = new sql_source_1.SQLSource().runSyntax(s, scope, filename);
|
|
24779
|
+
}
|
|
24780
|
+
const fieldName = (_a = node.findDirectExpression(Expressions.SQLFieldName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
24781
|
+
if (fieldName && sourceType && token) {
|
|
24782
|
+
// check compatibility for rule sql_value_conversion
|
|
24783
|
+
const targetType = this.findType(fieldName, tables, scope);
|
|
24784
|
+
let message = "";
|
|
24785
|
+
if (sourceType instanceof basic_1.IntegerType
|
|
24786
|
+
&& targetType instanceof basic_1.CharacterType) {
|
|
24787
|
+
message = "Integer to CHAR conversion";
|
|
24788
|
+
}
|
|
24789
|
+
else if (sourceType instanceof basic_1.IntegerType
|
|
24790
|
+
&& targetType instanceof basic_1.NumericType) {
|
|
24791
|
+
message = "Integer to NUMC conversion";
|
|
24792
|
+
}
|
|
24793
|
+
else if (sourceType instanceof basic_1.NumericType
|
|
24794
|
+
&& targetType instanceof basic_1.IntegerType) {
|
|
24795
|
+
message = "NUMC to Integer conversion";
|
|
24796
|
+
}
|
|
24797
|
+
else if (sourceType instanceof basic_1.CharacterType
|
|
24798
|
+
&& targetType instanceof basic_1.IntegerType) {
|
|
24799
|
+
message = "CHAR to Integer conversion";
|
|
24800
|
+
}
|
|
24801
|
+
else if (sourceType instanceof basic_1.CharacterType
|
|
24802
|
+
&& targetType instanceof basic_1.CharacterType
|
|
24803
|
+
&& sourceType.getLength() > targetType.getLength()) {
|
|
24804
|
+
message = "Source field longer than database field, CHAR -> CHAR";
|
|
24805
|
+
}
|
|
24806
|
+
else if (sourceType instanceof basic_1.NumericType
|
|
24807
|
+
&& targetType instanceof basic_1.NumericType
|
|
24808
|
+
&& sourceType.getLength() > targetType.getLength()) {
|
|
24809
|
+
message = "Source field longer than database field, NUMC -> NUMC";
|
|
24810
|
+
}
|
|
24811
|
+
if (message !== "") {
|
|
24812
|
+
scope.addSQLConversion(fieldName, message, token);
|
|
24813
|
+
}
|
|
24814
|
+
}
|
|
24815
|
+
}
|
|
24816
|
+
findType(fieldName, tables, scope) {
|
|
24817
|
+
for (const t of tables) {
|
|
24818
|
+
const type = t === null || t === void 0 ? void 0 : t.parseType(scope.getRegistry());
|
|
24819
|
+
if (type instanceof basic_1.StructureType) {
|
|
24820
|
+
return type.getComponentByName(fieldName);
|
|
24821
|
+
}
|
|
24822
|
+
}
|
|
24823
|
+
return undefined;
|
|
24824
|
+
}
|
|
24825
|
+
}
|
|
24826
|
+
exports.SQLCompare = SQLCompare;
|
|
24827
|
+
//# sourceMappingURL=sql_compare.js.map
|
|
24828
|
+
|
|
24829
|
+
/***/ }),
|
|
24830
|
+
|
|
24740
24831
|
/***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_for_all_entries.js":
|
|
24741
24832
|
/*!************************************************************************************************!*\
|
|
24742
24833
|
!*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_for_all_entries.js ***!
|
|
@@ -24789,6 +24880,7 @@ const dynamic_1 = __webpack_require__(/*! ./dynamic */ "./node_modules/@abaplint
|
|
|
24789
24880
|
const database_table_1 = __webpack_require__(/*! ./database_table */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/database_table.js");
|
|
24790
24881
|
class SQLFrom {
|
|
24791
24882
|
runSyntax(node, scope, filename) {
|
|
24883
|
+
const ret = [];
|
|
24792
24884
|
const fromList = node.findAllExpressions(Expressions.SQLFromSource);
|
|
24793
24885
|
for (const from of fromList) {
|
|
24794
24886
|
for (const d of from.findAllExpressions(Expressions.Dynamic)) {
|
|
@@ -24796,9 +24888,10 @@ class SQLFrom {
|
|
|
24796
24888
|
}
|
|
24797
24889
|
const dbtab = from.findFirstExpression(Expressions.DatabaseTable);
|
|
24798
24890
|
if (dbtab !== undefined) {
|
|
24799
|
-
new database_table_1.DatabaseTable().runSyntax(dbtab, scope, filename);
|
|
24891
|
+
ret.push(new database_table_1.DatabaseTable().runSyntax(dbtab, scope, filename));
|
|
24800
24892
|
}
|
|
24801
24893
|
}
|
|
24894
|
+
return ret;
|
|
24802
24895
|
}
|
|
24803
24896
|
}
|
|
24804
24897
|
exports.SQLFrom = SQLFrom;
|
|
@@ -24806,6 +24899,34 @@ exports.SQLFrom = SQLFrom;
|
|
|
24806
24899
|
|
|
24807
24900
|
/***/ }),
|
|
24808
24901
|
|
|
24902
|
+
/***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js":
|
|
24903
|
+
/*!***************************************************************************************!*\
|
|
24904
|
+
!*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/sql_source.js ***!
|
|
24905
|
+
\***************************************************************************************/
|
|
24906
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
24907
|
+
|
|
24908
|
+
"use strict";
|
|
24909
|
+
|
|
24910
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
24911
|
+
exports.SQLSource = void 0;
|
|
24912
|
+
const Expressions = __webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js");
|
|
24913
|
+
const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/source.js");
|
|
24914
|
+
class SQLSource {
|
|
24915
|
+
runSyntax(node, scope, filename) {
|
|
24916
|
+
for (const s of node.findAllExpressions(Expressions.Source)) {
|
|
24917
|
+
return new source_1.Source().runSyntax(s, scope, filename);
|
|
24918
|
+
}
|
|
24919
|
+
for (const s of node.findAllExpressions(Expressions.SimpleSource3)) {
|
|
24920
|
+
return new source_1.Source().runSyntax(s, scope, filename);
|
|
24921
|
+
}
|
|
24922
|
+
return undefined;
|
|
24923
|
+
}
|
|
24924
|
+
}
|
|
24925
|
+
exports.SQLSource = SQLSource;
|
|
24926
|
+
//# sourceMappingURL=sql_source.js.map
|
|
24927
|
+
|
|
24928
|
+
/***/ }),
|
|
24929
|
+
|
|
24809
24930
|
/***/ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/string_template.js":
|
|
24810
24931
|
/*!********************************************************************************************!*\
|
|
24811
24932
|
!*** ./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/string_template.js ***!
|
|
@@ -25403,6 +25524,7 @@ class ScopeData {
|
|
|
25403
25524
|
extraLikeTypes: {},
|
|
25404
25525
|
deferred: [],
|
|
25405
25526
|
references: [],
|
|
25527
|
+
sqlConversion: [],
|
|
25406
25528
|
};
|
|
25407
25529
|
}
|
|
25408
25530
|
getData() {
|
|
@@ -46811,7 +46933,7 @@ class Registry {
|
|
|
46811
46933
|
}
|
|
46812
46934
|
static abaplintVersion() {
|
|
46813
46935
|
// magic, see build script "version.sh"
|
|
46814
|
-
return "2.
|
|
46936
|
+
return "2.101.0";
|
|
46815
46937
|
}
|
|
46816
46938
|
getDDICReferences() {
|
|
46817
46939
|
return this.ddicReferences;
|
|
@@ -53453,11 +53575,12 @@ ${indentation} output = ${topTarget}.`;
|
|
|
53453
53575
|
body += indentation + structureName + "-" + b.concatTokens() + ".\n";
|
|
53454
53576
|
}
|
|
53455
53577
|
else if (b.get() instanceof Expressions.Source) {
|
|
53456
|
-
|
|
53578
|
+
// note: it wont work with APPEND for Hashed/Sorted Tables, so use INSERT,
|
|
53579
|
+
body += indentation + "INSERT " + b.concatTokens() + ` INTO TABLE ${uniqueName}.\n`;
|
|
53457
53580
|
skip = true;
|
|
53458
53581
|
}
|
|
53459
53582
|
else if (b.get() instanceof Expressions.ValueBodyLines) {
|
|
53460
|
-
body += indentation + "
|
|
53583
|
+
body += indentation + "INSERT " + b.concatTokens() + ` INTO TABLE ${uniqueName}.\n`;
|
|
53461
53584
|
skip = true;
|
|
53462
53585
|
}
|
|
53463
53586
|
else if (b.concatTokens() === ")") {
|
|
@@ -53466,7 +53589,7 @@ ${indentation} output = ${topTarget}.`;
|
|
|
53466
53589
|
added = true;
|
|
53467
53590
|
}
|
|
53468
53591
|
if (skip === false) {
|
|
53469
|
-
body += indentation + `
|
|
53592
|
+
body += indentation + `INSERT ${structureName} INTO TABLE ${uniqueName}.\n`;
|
|
53470
53593
|
}
|
|
53471
53594
|
}
|
|
53472
53595
|
previous = b;
|
|
@@ -56151,7 +56274,16 @@ IF condition1.
|
|
|
56151
56274
|
...
|
|
56152
56275
|
ELSEIF condition2.
|
|
56153
56276
|
...
|
|
56154
|
-
ENDIF
|
|
56277
|
+
ENDIF.
|
|
56278
|
+
|
|
56279
|
+
CASE variable.
|
|
56280
|
+
WHEN value1.
|
|
56281
|
+
...
|
|
56282
|
+
WHEN value2.
|
|
56283
|
+
IF condition2.
|
|
56284
|
+
...
|
|
56285
|
+
ENDIF.
|
|
56286
|
+
ENDCASE.`,
|
|
56155
56287
|
tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
|
|
56156
56288
|
};
|
|
56157
56289
|
}
|
|
@@ -56896,6 +57028,7 @@ __exportStar(__webpack_require__(/*! ./smim_consistency */ "./node_modules/@abap
|
|
|
56896
57028
|
__exportStar(__webpack_require__(/*! ./space_before_colon */ "./node_modules/@abaplint/core/build/src/rules/space_before_colon.js"), exports);
|
|
56897
57029
|
__exportStar(__webpack_require__(/*! ./space_before_dot */ "./node_modules/@abaplint/core/build/src/rules/space_before_dot.js"), exports);
|
|
56898
57030
|
__exportStar(__webpack_require__(/*! ./sql_escape_host_variables */ "./node_modules/@abaplint/core/build/src/rules/sql_escape_host_variables.js"), exports);
|
|
57031
|
+
__exportStar(__webpack_require__(/*! ./sql_value_conversion */ "./node_modules/@abaplint/core/build/src/rules/sql_value_conversion.js"), exports);
|
|
56899
57032
|
__exportStar(__webpack_require__(/*! ./start_at_tab */ "./node_modules/@abaplint/core/build/src/rules/start_at_tab.js"), exports);
|
|
56900
57033
|
__exportStar(__webpack_require__(/*! ./static_call_via_instance */ "./node_modules/@abaplint/core/build/src/rules/static_call_via_instance.js"), exports);
|
|
56901
57034
|
__exportStar(__webpack_require__(/*! ./strict_sql */ "./node_modules/@abaplint/core/build/src/rules/strict_sql.js"), exports);
|
|
@@ -62480,6 +62613,9 @@ class ReduceStringTemplates extends _abap_rule_1.ABAPRule {
|
|
|
62480
62613
|
for (const second of source.findDirectExpressions(Expressions.StringTemplate)) {
|
|
62481
62614
|
issues.push(issue_1.Issue.atToken(file, second.getFirstToken(), "Nested string templates, reduce", this.getMetadata().key, this.conf.severity));
|
|
62482
62615
|
}
|
|
62616
|
+
if (ts.findDirectExpression(Expressions.StringTemplateFormatting)) {
|
|
62617
|
+
continue;
|
|
62618
|
+
}
|
|
62483
62619
|
for (const constant of source.findDirectExpressions(Expressions.Constant)) {
|
|
62484
62620
|
for (const constantString of constant.findDirectExpressions(Expressions.ConstantString)) {
|
|
62485
62621
|
issues.push(issue_1.Issue.atToken(file, constantString.getFirstToken(), "Constant string in text template, reduce", this.getMetadata().key, this.conf.severity));
|
|
@@ -64021,6 +64157,81 @@ exports.SQLEscapeHostVariables = SQLEscapeHostVariables;
|
|
|
64021
64157
|
|
|
64022
64158
|
/***/ }),
|
|
64023
64159
|
|
|
64160
|
+
/***/ "./node_modules/@abaplint/core/build/src/rules/sql_value_conversion.js":
|
|
64161
|
+
/*!*****************************************************************************!*\
|
|
64162
|
+
!*** ./node_modules/@abaplint/core/build/src/rules/sql_value_conversion.js ***!
|
|
64163
|
+
\*****************************************************************************/
|
|
64164
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
64165
|
+
|
|
64166
|
+
"use strict";
|
|
64167
|
+
|
|
64168
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
64169
|
+
exports.SQLValueConversion = exports.SQLValueConversionConf = void 0;
|
|
64170
|
+
const issue_1 = __webpack_require__(/*! ../issue */ "./node_modules/@abaplint/core/build/src/issue.js");
|
|
64171
|
+
const _basic_rule_config_1 = __webpack_require__(/*! ./_basic_rule_config */ "./node_modules/@abaplint/core/build/src/rules/_basic_rule_config.js");
|
|
64172
|
+
const objects_1 = __webpack_require__(/*! ../objects */ "./node_modules/@abaplint/core/build/src/objects/index.js");
|
|
64173
|
+
const syntax_1 = __webpack_require__(/*! ../abap/5_syntax/syntax */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/syntax.js");
|
|
64174
|
+
const _abap_object_1 = __webpack_require__(/*! ../objects/_abap_object */ "./node_modules/@abaplint/core/build/src/objects/_abap_object.js");
|
|
64175
|
+
class SQLValueConversionConf extends _basic_rule_config_1.BasicRuleConfig {
|
|
64176
|
+
}
|
|
64177
|
+
exports.SQLValueConversionConf = SQLValueConversionConf;
|
|
64178
|
+
class SQLValueConversion {
|
|
64179
|
+
constructor() {
|
|
64180
|
+
this.conf = new SQLValueConversionConf();
|
|
64181
|
+
}
|
|
64182
|
+
getMetadata() {
|
|
64183
|
+
return {
|
|
64184
|
+
key: "sql_value_conversion",
|
|
64185
|
+
title: "Implicit SQL Value Conversion",
|
|
64186
|
+
shortDescription: `Ensure types match when selecting from database`,
|
|
64187
|
+
extendedInformation: `
|
|
64188
|
+
* Integer to CHAR conversion
|
|
64189
|
+
* Integer to NUMC conversion
|
|
64190
|
+
* NUMC to Integer conversion
|
|
64191
|
+
* CHAR to Integer conversion
|
|
64192
|
+
* Source field longer than database field, CHAR -> CHAR
|
|
64193
|
+
* Source field longer than database field, NUMC -> NUMC`,
|
|
64194
|
+
tags: [],
|
|
64195
|
+
};
|
|
64196
|
+
}
|
|
64197
|
+
getConfig() {
|
|
64198
|
+
return this.conf;
|
|
64199
|
+
}
|
|
64200
|
+
setConfig(conf) {
|
|
64201
|
+
this.conf = conf;
|
|
64202
|
+
}
|
|
64203
|
+
initialize(reg) {
|
|
64204
|
+
this.reg = reg;
|
|
64205
|
+
return this;
|
|
64206
|
+
}
|
|
64207
|
+
run(obj) {
|
|
64208
|
+
if (!(obj instanceof _abap_object_1.ABAPObject) || obj instanceof objects_1.Interface) {
|
|
64209
|
+
return [];
|
|
64210
|
+
}
|
|
64211
|
+
// messages defined in sql_compare.ts
|
|
64212
|
+
const issues = this.traverse(new syntax_1.SyntaxLogic(this.reg, obj).run().spaghetti.getTop());
|
|
64213
|
+
return issues;
|
|
64214
|
+
}
|
|
64215
|
+
traverse(node) {
|
|
64216
|
+
const ret = [];
|
|
64217
|
+
for (const r of node.getData().sqlConversion) {
|
|
64218
|
+
const file = this.reg.getFileByName(node.getIdentifier().filename);
|
|
64219
|
+
if (file === undefined) {
|
|
64220
|
+
continue;
|
|
64221
|
+
}
|
|
64222
|
+
ret.push(issue_1.Issue.atToken(file, r.token, r.message, this.getMetadata().key, this.getConfig().severity));
|
|
64223
|
+
}
|
|
64224
|
+
for (const c of node.getChildren()) {
|
|
64225
|
+
ret.push(...this.traverse(c));
|
|
64226
|
+
}
|
|
64227
|
+
return ret;
|
|
64228
|
+
}
|
|
64229
|
+
}
|
|
64230
|
+
exports.SQLValueConversion = SQLValueConversion;
|
|
64231
|
+
//# sourceMappingURL=sql_value_conversion.js.map
|
|
64232
|
+
|
|
64233
|
+
/***/ }),
|
|
64234
|
+
|
|
64024
64235
|
/***/ "./node_modules/@abaplint/core/build/src/rules/start_at_tab.js":
|
|
64025
64236
|
/*!*********************************************************************!*\
|
|
64026
64237
|
!*** ./node_modules/@abaplint/core/build/src/rules/start_at_tab.js ***!
|
|
@@ -64770,13 +64981,15 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
|
|
|
64770
64981
|
if (stat.get() instanceof Statements.Type && nesting === 0) {
|
|
64771
64982
|
expr = stat.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
64772
64983
|
}
|
|
64773
|
-
else if (stat.get() instanceof Statements.TypeBegin
|
|
64984
|
+
else if (stat.get() instanceof Statements.TypeBegin
|
|
64985
|
+
|| stat.get() instanceof Statements.TypeEnumBegin) {
|
|
64774
64986
|
if (nesting === 0) {
|
|
64775
64987
|
expr = stat.findFirstExpression(Expressions.NamespaceSimpleName);
|
|
64776
64988
|
}
|
|
64777
64989
|
nesting = nesting + 1;
|
|
64778
64990
|
}
|
|
64779
|
-
else if (stat.get() instanceof Statements.TypeEnd
|
|
64991
|
+
else if (stat.get() instanceof Statements.TypeEnd
|
|
64992
|
+
|| stat.get() instanceof Statements.TypeEnumEnd) {
|
|
64780
64993
|
nesting = nesting - 1;
|
|
64781
64994
|
continue;
|
|
64782
64995
|
}
|
|
@@ -70392,8 +70605,9 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
|
|
|
70392
70605
|
const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_modules/@abaplint/transpiler/build/src/expressions/simple_source3.js");
|
|
70393
70606
|
const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
|
|
70394
70607
|
const sql_field_name_1 = __webpack_require__(/*! ./sql_field_name */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_name.js");
|
|
70608
|
+
const transpile_types_1 = __webpack_require__(/*! ../transpile_types */ "./node_modules/@abaplint/transpiler/build/src/transpile_types.js");
|
|
70395
70609
|
class SQLCondTranspiler {
|
|
70396
|
-
transpile(node, traversal) {
|
|
70610
|
+
transpile(node, traversal, table) {
|
|
70397
70611
|
var _a;
|
|
70398
70612
|
let ret = "";
|
|
70399
70613
|
for (const c of node.getChildren()) {
|
|
@@ -70416,11 +70630,11 @@ class SQLCondTranspiler {
|
|
|
70416
70630
|
ret += this.sqlIn(c, traversal);
|
|
70417
70631
|
}
|
|
70418
70632
|
else {
|
|
70419
|
-
ret += this.basicCondition(c, traversal, traversal.getFilename());
|
|
70633
|
+
ret += this.basicCondition(c, traversal, traversal.getFilename(), table);
|
|
70420
70634
|
}
|
|
70421
70635
|
}
|
|
70422
70636
|
else if (c instanceof abaplint.Nodes.ExpressionNode) {
|
|
70423
|
-
ret += " " + this.transpile(c, traversal).getCode();
|
|
70637
|
+
ret += " " + this.transpile(c, traversal, table).getCode();
|
|
70424
70638
|
}
|
|
70425
70639
|
else {
|
|
70426
70640
|
ret += " " + c.concatTokens();
|
|
@@ -70439,10 +70653,10 @@ class SQLCondTranspiler {
|
|
|
70439
70653
|
const ret = `" + abap.expandIN("${fieldName.concatTokens()}", ${source.concatTokens()}) + "`;
|
|
70440
70654
|
return ret;
|
|
70441
70655
|
}
|
|
70442
|
-
basicCondition(c, traversal, filename) {
|
|
70656
|
+
basicCondition(c, traversal, filename, table) {
|
|
70443
70657
|
let ret = "";
|
|
70444
70658
|
if (c.getChildren().length !== 3) {
|
|
70445
|
-
return this.basicConditionNew(c, traversal, filename);
|
|
70659
|
+
return this.basicConditionNew(c, traversal, filename, table);
|
|
70446
70660
|
}
|
|
70447
70661
|
let fieldName = undefined;
|
|
70448
70662
|
const fieldNameExpression = c.findDirectExpression(abaplint.Expressions.SQLFieldName);
|
|
@@ -70453,7 +70667,7 @@ class SQLCondTranspiler {
|
|
|
70453
70667
|
const source = c.findDirectExpression(abaplint.Expressions.SQLSource);
|
|
70454
70668
|
if (fieldName && source && operator === undefined && c.findDirectTokenByText("LIKE")) {
|
|
70455
70669
|
ret += fieldName + " LIKE ";
|
|
70456
|
-
ret += this.sqlSource(source, traversal, filename);
|
|
70670
|
+
ret += this.sqlSource(source, traversal, filename, table);
|
|
70457
70671
|
return ret;
|
|
70458
70672
|
}
|
|
70459
70673
|
if (fieldName === undefined || operator === undefined || source === undefined) {
|
|
@@ -70467,10 +70681,10 @@ class SQLCondTranspiler {
|
|
|
70467
70681
|
op = "<>";
|
|
70468
70682
|
}
|
|
70469
70683
|
ret += fieldName + " " + op + " ";
|
|
70470
|
-
ret += this.sqlSource(source, traversal, filename);
|
|
70684
|
+
ret += this.sqlSource(source, traversal, filename, table);
|
|
70471
70685
|
return ret;
|
|
70472
70686
|
}
|
|
70473
|
-
sqlSource(source, traversal, filename) {
|
|
70687
|
+
sqlSource(source, traversal, filename, table) {
|
|
70474
70688
|
let ret = "";
|
|
70475
70689
|
const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
|
|
70476
70690
|
const alias = source.findDirectExpression(abaplint.Expressions.SQLAliasField);
|
|
@@ -70496,7 +70710,12 @@ class SQLCondTranspiler {
|
|
|
70496
70710
|
}
|
|
70497
70711
|
else {
|
|
70498
70712
|
const concat = source.concatTokens();
|
|
70499
|
-
|
|
70713
|
+
const conversionField = traversal.isSQLConversion(source.getFirstToken());
|
|
70714
|
+
if (conversionField) {
|
|
70715
|
+
const field = (table === null || table === void 0 ? void 0 : table.parseType(traversal.reg)).getComponentByName(conversionField);
|
|
70716
|
+
ret += "'\" + " + new transpile_types_1.TranspileTypes().toType(field) + ".set(" + concat + ").get() + \"'";
|
|
70717
|
+
}
|
|
70718
|
+
else if (concat.startsWith("`")) {
|
|
70500
70719
|
ret += "'" + concat.substring(1, concat.length - 1) + "'";
|
|
70501
70720
|
}
|
|
70502
70721
|
else {
|
|
@@ -70505,7 +70724,7 @@ class SQLCondTranspiler {
|
|
|
70505
70724
|
}
|
|
70506
70725
|
return ret;
|
|
70507
70726
|
}
|
|
70508
|
-
basicConditionNew(node, traversal, filename) {
|
|
70727
|
+
basicConditionNew(node, traversal, filename, table) {
|
|
70509
70728
|
let ret = "";
|
|
70510
70729
|
for (const child of node.getChildren()) {
|
|
70511
70730
|
if (ret !== "") {
|
|
@@ -70517,7 +70736,7 @@ class SQLCondTranspiler {
|
|
|
70517
70736
|
}
|
|
70518
70737
|
else if (child.get() instanceof abaplint.Expressions.SQLSource
|
|
70519
70738
|
&& child instanceof abaplint.Nodes.ExpressionNode) {
|
|
70520
|
-
ret += this.sqlSource(child, traversal, filename);
|
|
70739
|
+
ret += this.sqlSource(child, traversal, filename, table);
|
|
70521
70740
|
}
|
|
70522
70741
|
else {
|
|
70523
70742
|
ret += child.concatTokens();
|
|
@@ -70625,13 +70844,19 @@ class SQLFromTranspiler {
|
|
|
70625
70844
|
}
|
|
70626
70845
|
else {
|
|
70627
70846
|
if (c.findFirstExpression(abaplint.Expressions.Dynamic)) {
|
|
70628
|
-
|
|
70847
|
+
let concat = c.concatTokens();
|
|
70848
|
+
if (concat.startsWith("'")) {
|
|
70849
|
+
// no escaping needed, guess its not possible to have table names with single or double quote part of name
|
|
70850
|
+
concat = "\\\"" + concat.substring(1, concat.length - 1) + "\\\"";
|
|
70851
|
+
}
|
|
70852
|
+
chunk.appendString(concat + " ");
|
|
70629
70853
|
}
|
|
70630
70854
|
else if (c.concatTokens().includes("/")) {
|
|
70631
|
-
chunk.appendString("
|
|
70855
|
+
chunk.appendString("\\\"" + c.concatTokens() + "\\\" ");
|
|
70632
70856
|
}
|
|
70633
70857
|
else {
|
|
70634
|
-
|
|
70858
|
+
const concat = c.concatTokens();
|
|
70859
|
+
chunk.appendString(concat + " ");
|
|
70635
70860
|
}
|
|
70636
70861
|
}
|
|
70637
70862
|
}
|
|
@@ -70664,7 +70889,11 @@ class SQLFromSourceTranspiler {
|
|
|
70664
70889
|
chunk.appendString(c.concatTokens() + " ");
|
|
70665
70890
|
}
|
|
70666
70891
|
else if (c.get() instanceof abaplint.Expressions.DatabaseTable && c.concatTokens().includes("/")) {
|
|
70667
|
-
chunk.appendString("
|
|
70892
|
+
chunk.appendString("\"" + c.concatTokens() + "\" ");
|
|
70893
|
+
}
|
|
70894
|
+
else if (c.get() instanceof abaplint.Expressions.DatabaseTable && c.concatTokens().startsWith("('")) {
|
|
70895
|
+
const concat = c.concatTokens();
|
|
70896
|
+
chunk.appendString("\\\"" + concat.substring(2, concat.length - 2).toLowerCase() + "\\\" ");
|
|
70668
70897
|
}
|
|
70669
70898
|
else {
|
|
70670
70899
|
chunk.appendString(c.concatTokens() + " ");
|
|
@@ -74752,7 +74981,7 @@ class InsertDatabaseTranspiler {
|
|
|
74752
74981
|
const tvalues = traversal.traverse(fromTable);
|
|
74753
74982
|
options.push(`"table": ` + tvalues.getCode());
|
|
74754
74983
|
}
|
|
74755
|
-
return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode()}, {${options.join(", ")}});`);
|
|
74984
|
+
return new chunk_1.Chunk(`await abap.statements.insertDatabase(${table.getCode().toLowerCase()}, {${options.join(", ")}});`);
|
|
74756
74985
|
}
|
|
74757
74986
|
}
|
|
74758
74987
|
exports.InsertDatabaseTranspiler = InsertDatabaseTranspiler;
|
|
@@ -76228,6 +76457,7 @@ class SelectTranspiler {
|
|
|
76228
76457
|
if (from) {
|
|
76229
76458
|
select += new sql_from_1.SQLFromTranspiler().transpile(from, traversal).getCode();
|
|
76230
76459
|
}
|
|
76460
|
+
const { table, keys } = this.findTable(node, traversal);
|
|
76231
76461
|
let where = undefined;
|
|
76232
76462
|
for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {
|
|
76233
76463
|
if (this.isWhereExpression(node, sqlCond)) {
|
|
@@ -76235,7 +76465,7 @@ class SelectTranspiler {
|
|
|
76235
76465
|
}
|
|
76236
76466
|
}
|
|
76237
76467
|
if (where) {
|
|
76238
|
-
select += "WHERE " +
|
|
76468
|
+
select += "WHERE " + new expressions_1.SQLCondTranspiler().transpile(where, traversal, table).getCode() + " ";
|
|
76239
76469
|
}
|
|
76240
76470
|
const upTo = node.findFirstExpression(abaplint.Expressions.SQLUpTo);
|
|
76241
76471
|
if (upTo) {
|
|
@@ -76271,7 +76501,6 @@ class SelectTranspiler {
|
|
|
76271
76501
|
runtimeOptions = `, {` + runtimeOptionsList.join(", ") + `}`;
|
|
76272
76502
|
}
|
|
76273
76503
|
let extra = "";
|
|
76274
|
-
const keys = this.findKeys(node, traversal);
|
|
76275
76504
|
if (keys.length > 0) {
|
|
76276
76505
|
extra = `, primaryKey: ${JSON.stringify(keys)}`;
|
|
76277
76506
|
}
|
|
@@ -76304,16 +76533,17 @@ class SelectTranspiler {
|
|
|
76304
76533
|
return new chunk_1.Chunk().append(`await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}${runtimeOptions});`, node, traversal);
|
|
76305
76534
|
}
|
|
76306
76535
|
}
|
|
76307
|
-
|
|
76536
|
+
findTable(node, traversal) {
|
|
76308
76537
|
let keys = [];
|
|
76538
|
+
let tabl = undefined;
|
|
76309
76539
|
const from = node.findAllExpressions(abaplint.Expressions.SQLFromSource).map(e => e.concatTokens());
|
|
76310
76540
|
if (from.length === 1) {
|
|
76311
|
-
|
|
76541
|
+
tabl = traversal.findTable(from[0]);
|
|
76312
76542
|
if (tabl) {
|
|
76313
76543
|
keys = tabl.listKeys(traversal.reg).map(k => k.toLowerCase());
|
|
76314
76544
|
}
|
|
76315
76545
|
}
|
|
76316
|
-
return keys;
|
|
76546
|
+
return { table: tabl, keys };
|
|
76317
76547
|
}
|
|
76318
76548
|
isWhereExpression(node, expression) {
|
|
76319
76549
|
// check if previous token before sqlCond is "WHERE". It could also be "ON" in case of join condition
|
|
@@ -77097,7 +77327,7 @@ class UpdateDatabaseTranspiler {
|
|
|
77097
77327
|
for (const set of sets) {
|
|
77098
77328
|
const name = (_a = set.findDirectExpression(abaplint.Expressions.SQLFieldName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
|
|
77099
77329
|
const source = traversal.traverse(set.findDirectExpression(abaplint.Expressions.SQLSource));
|
|
77100
|
-
s.push("\"
|
|
77330
|
+
s.push("\"\\\"" + name + "\\\" = '\" + " + source.getCode() + ".get() + \"'\"");
|
|
77101
77331
|
}
|
|
77102
77332
|
options.push(`"set": [${s.join(",")}]`);
|
|
77103
77333
|
}
|
|
@@ -78798,6 +79028,15 @@ class Traversal {
|
|
|
78798
79028
|
}
|
|
78799
79029
|
return false;
|
|
78800
79030
|
}
|
|
79031
|
+
isSQLConversion(token) {
|
|
79032
|
+
const scope = this.findCurrentScopeByToken(token);
|
|
79033
|
+
for (const s of (scope === null || scope === void 0 ? void 0 : scope.getData().sqlConversion) || []) {
|
|
79034
|
+
if (s.token.getStart().equals(token.getStart())) {
|
|
79035
|
+
return s.fieldName;
|
|
79036
|
+
}
|
|
79037
|
+
}
|
|
79038
|
+
return undefined;
|
|
79039
|
+
}
|
|
78801
79040
|
findMethodReference(token, scope) {
|
|
78802
79041
|
var _a, _b;
|
|
78803
79042
|
let candidate = undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/transpiler-cli",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.6",
|
|
4
4
|
"description": "Transpiler - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"author": "abaplint",
|
|
27
27
|
"license": "MIT",
|
|
28
28
|
"devDependencies": {
|
|
29
|
-
"@abaplint/transpiler": "^2.7.
|
|
29
|
+
"@abaplint/transpiler": "^2.7.6",
|
|
30
30
|
"@types/glob": "^7.2.0",
|
|
31
31
|
"glob": "=7.2.0",
|
|
32
32
|
"@types/progress": "^2.0.5",
|
|
33
33
|
"@types/node": "^20.2.1",
|
|
34
|
-
"@abaplint/core": "^2.
|
|
34
|
+
"@abaplint/core": "^2.101.0",
|
|
35
35
|
"progress": "^2.0.3",
|
|
36
36
|
"webpack": "^5.83.1",
|
|
37
37
|
"webpack-cli": "^5.1.1",
|