@abaplint/cli 2.120.98 → 2.120.100
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/cli.js +144 -31
- package/package.json +2 -2
package/build/cli.js
CHANGED
|
@@ -35457,6 +35457,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
35457
35457
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
35458
35458
|
exports.Select = void 0;
|
|
35459
35459
|
const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "../core/build/src/abap/2_statements/expressions/index.js"));
|
|
35460
|
+
const nodes_1 = __webpack_require__(/*! ../../nodes */ "../core/build/src/abap/nodes/index.js");
|
|
35460
35461
|
const basic_1 = __webpack_require__(/*! ../../types/basic */ "../core/build/src/abap/types/basic/index.js");
|
|
35461
35462
|
const inline_data_1 = __webpack_require__(/*! ./inline_data */ "../core/build/src/abap/5_syntax/expressions/inline_data.js");
|
|
35462
35463
|
const target_1 = __webpack_require__(/*! ./target */ "../core/build/src/abap/5_syntax/expressions/target.js");
|
|
@@ -35472,6 +35473,8 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "../core/bui
|
|
|
35472
35473
|
const version_1 = __webpack_require__(/*! ../../../version */ "../core/build/src/version.js");
|
|
35473
35474
|
const _check_database_fields_1 = __webpack_require__(/*! ./_check_database_fields */ "../core/build/src/abap/5_syntax/expressions/_check_database_fields.js");
|
|
35474
35475
|
const isSimple = /^\w+$/;
|
|
35476
|
+
// SQL functions where the result has the same type as the first argument
|
|
35477
|
+
const sameTypeAsFirstArgument = new Set(["UPPER", "LOWER", "LTRIM", "RTRIM"]);
|
|
35475
35478
|
class Select {
|
|
35476
35479
|
static runSyntax(node, input, skipImplicitInto = false, selectLoop = false) {
|
|
35477
35480
|
var _a;
|
|
@@ -35677,7 +35680,7 @@ class Select {
|
|
|
35677
35680
|
if (intoStructure) {
|
|
35678
35681
|
const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
|
|
35679
35682
|
if (inlineList.length === 1) {
|
|
35680
|
-
inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope));
|
|
35683
|
+
inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope, from));
|
|
35681
35684
|
}
|
|
35682
35685
|
else {
|
|
35683
35686
|
for (const inline of inlineList) {
|
|
@@ -35707,7 +35710,12 @@ class Select {
|
|
|
35707
35710
|
return;
|
|
35708
35711
|
}
|
|
35709
35712
|
let type = basic_1.VoidType.get("SELECT_todo2");
|
|
35710
|
-
|
|
35713
|
+
const fn = this.findFunctionColumn(field, false);
|
|
35714
|
+
if (fn) {
|
|
35715
|
+
const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
|
|
35716
|
+
type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, input.scope)) || type;
|
|
35717
|
+
}
|
|
35718
|
+
else if (isSimple.test(field.code)) {
|
|
35711
35719
|
for (const dbSource of dbSources) {
|
|
35712
35720
|
if (dbSource === undefined) {
|
|
35713
35721
|
continue;
|
|
@@ -35739,7 +35747,7 @@ class Select {
|
|
|
35739
35747
|
return basic_1.IntegerType.get();
|
|
35740
35748
|
}
|
|
35741
35749
|
}
|
|
35742
|
-
static buildStructureType(fields, dbSources, scope) {
|
|
35750
|
+
static buildStructureType(fields, dbSources, scope, from) {
|
|
35743
35751
|
var _a, _b, _c, _d, _e, _f;
|
|
35744
35752
|
if (fields.length === 1 && dbSources.length === 1) {
|
|
35745
35753
|
// COUNT( * ) yields an integer regardless of the (possibly dynamic) table
|
|
@@ -35775,10 +35783,16 @@ class Select {
|
|
|
35775
35783
|
return basic_1.IntegerType.get();
|
|
35776
35784
|
}
|
|
35777
35785
|
}
|
|
35778
|
-
|
|
35779
|
-
|
|
35780
|
-
|
|
35786
|
+
const fn = this.findFunctionColumn(fields[0], false);
|
|
35787
|
+
if (fn) {
|
|
35788
|
+
const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
|
|
35789
|
+
const type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, scope));
|
|
35790
|
+
if (type) {
|
|
35791
|
+
return type;
|
|
35792
|
+
}
|
|
35781
35793
|
}
|
|
35794
|
+
// todo: aggregated/calculated values
|
|
35795
|
+
return basic_1.VoidType.get("SELECT_todo11");
|
|
35782
35796
|
}
|
|
35783
35797
|
else {
|
|
35784
35798
|
return basic_1.VoidType.get("SELECT_todo10");
|
|
@@ -35799,15 +35813,10 @@ class Select {
|
|
|
35799
35813
|
if (!(dbType instanceof basic_1.StructureType)) {
|
|
35800
35814
|
return basic_1.VoidType.get("SELECT_todo14");
|
|
35801
35815
|
}
|
|
35802
|
-
|
|
35803
|
-
|
|
35804
|
-
|
|
35805
|
-
|
|
35806
|
-
const type = dbType.getComponentByName(field.code);
|
|
35807
|
-
if (type === undefined) {
|
|
35808
|
-
return basic_1.VoidType.get("SELECT_todo9");
|
|
35809
|
-
}
|
|
35810
|
-
components.push({ name: field.as || field.code, type });
|
|
35816
|
+
if (this.allFieldsSupported(fields) === true) {
|
|
35817
|
+
const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
|
|
35818
|
+
if (components === undefined) {
|
|
35819
|
+
return basic_1.VoidType.get("SELECT_todo9");
|
|
35811
35820
|
}
|
|
35812
35821
|
return new basic_1.StructureType(components);
|
|
35813
35822
|
}
|
|
@@ -35833,9 +35842,15 @@ class Select {
|
|
|
35833
35842
|
}
|
|
35834
35843
|
return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
|
|
35835
35844
|
}
|
|
35845
|
+
const lookup = code => this.findFieldType(code, sourceInfos, scope);
|
|
35836
35846
|
const components = [];
|
|
35837
35847
|
for (const field of fields) {
|
|
35838
|
-
const
|
|
35848
|
+
const fn = this.findFunctionColumn(field);
|
|
35849
|
+
if (fn) {
|
|
35850
|
+
components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
|
|
35851
|
+
continue;
|
|
35852
|
+
}
|
|
35853
|
+
const type = lookup(field.code);
|
|
35839
35854
|
if (type === undefined) {
|
|
35840
35855
|
return basic_1.VoidType.get("SELECT_todo3");
|
|
35841
35856
|
}
|
|
@@ -35858,20 +35873,101 @@ class Select {
|
|
|
35858
35873
|
if (fields.length === 1 && fields[0].code === "*") {
|
|
35859
35874
|
return new basic_1.TableType(dbType, tableOptions, undefined);
|
|
35860
35875
|
}
|
|
35861
|
-
|
|
35862
|
-
|
|
35863
|
-
|
|
35864
|
-
|
|
35865
|
-
const type = dbType.getComponentByName(field.code);
|
|
35866
|
-
if (type === undefined) {
|
|
35867
|
-
return basic_1.VoidType.get("SELECT_todo6");
|
|
35868
|
-
}
|
|
35869
|
-
components.push({ name: field.as || field.code, type });
|
|
35876
|
+
if (this.allFieldsSupported(fields) === true) {
|
|
35877
|
+
const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
|
|
35878
|
+
if (components === undefined) {
|
|
35879
|
+
return basic_1.VoidType.get("SELECT_todo6");
|
|
35870
35880
|
}
|
|
35871
35881
|
return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
|
|
35872
35882
|
}
|
|
35873
35883
|
return basic_1.VoidType.get("SELECT_todo7");
|
|
35874
35884
|
}
|
|
35885
|
+
/** plain field names, or SQL function columns with an alias */
|
|
35886
|
+
static allFieldsSupported(fields) {
|
|
35887
|
+
return fields.every(f => isSimple.test(f.code) || this.findFunctionColumn(f) !== undefined);
|
|
35888
|
+
}
|
|
35889
|
+
/** returns undefined if a plain field is not found in the database table */
|
|
35890
|
+
static buildSingleSourceComponents(fields, dbType, from, dbSources, scope) {
|
|
35891
|
+
const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
|
|
35892
|
+
const lookup = code => this.findFieldType(code, sourceInfos, scope);
|
|
35893
|
+
const components = [];
|
|
35894
|
+
for (const field of fields) {
|
|
35895
|
+
const fn = this.findFunctionColumn(field);
|
|
35896
|
+
if (fn) {
|
|
35897
|
+
components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
|
|
35898
|
+
continue;
|
|
35899
|
+
}
|
|
35900
|
+
const type = dbType.getComponentByName(field.code);
|
|
35901
|
+
if (type === undefined) {
|
|
35902
|
+
return undefined;
|
|
35903
|
+
}
|
|
35904
|
+
components.push({ name: field.as || field.code, type });
|
|
35905
|
+
}
|
|
35906
|
+
return components;
|
|
35907
|
+
}
|
|
35908
|
+
/** returns the SQLFunction node if the field list entry is a single SQL function call */
|
|
35909
|
+
static findFunctionColumn(field, requireAlias = true) {
|
|
35910
|
+
if (requireAlias === true && field.as === "") {
|
|
35911
|
+
return undefined;
|
|
35912
|
+
}
|
|
35913
|
+
else if (!(field.expression.get() instanceof Expressions.SQLField)) {
|
|
35914
|
+
return undefined;
|
|
35915
|
+
}
|
|
35916
|
+
const children = field.expression.getChildren().filter(c => !(c.get() instanceof Expressions.SQLAsName) && c.concatTokens().toUpperCase() !== "AS");
|
|
35917
|
+
if (children.length === 1
|
|
35918
|
+
&& children[0] instanceof nodes_1.ExpressionNode
|
|
35919
|
+
&& children[0].get() instanceof Expressions.SQLFunction) {
|
|
35920
|
+
return children[0];
|
|
35921
|
+
}
|
|
35922
|
+
return undefined;
|
|
35923
|
+
}
|
|
35924
|
+
/** infers the result type of a SQL function, returns undefined if not possible */
|
|
35925
|
+
static inferFunctionType(fn, lookup) {
|
|
35926
|
+
const name = fn.getFirstToken().getStr().toUpperCase();
|
|
35927
|
+
const inputs = fn.findDirectExpressions(Expressions.SQLFunctionInput);
|
|
35928
|
+
if (inputs.length === 0) {
|
|
35929
|
+
return undefined;
|
|
35930
|
+
}
|
|
35931
|
+
if (name === "SUBSTRING" && inputs.length === 3) {
|
|
35932
|
+
const len = inputs[2].concatTokens();
|
|
35933
|
+
if (/^\d+$/.test(len) === false || parseInt(len, 10) <= 0) {
|
|
35934
|
+
return undefined;
|
|
35935
|
+
}
|
|
35936
|
+
const argType = this.inferFunctionInputType(inputs[0], lookup);
|
|
35937
|
+
if (argType instanceof basic_1.StringType) {
|
|
35938
|
+
return argType;
|
|
35939
|
+
}
|
|
35940
|
+
else if (argType instanceof basic_1.CharacterType
|
|
35941
|
+
|| argType instanceof basic_1.NumericType
|
|
35942
|
+
|| argType instanceof basic_1.DateType
|
|
35943
|
+
|| argType instanceof basic_1.TimeType) {
|
|
35944
|
+
return new basic_1.CharacterType(parseInt(len, 10));
|
|
35945
|
+
}
|
|
35946
|
+
return undefined;
|
|
35947
|
+
}
|
|
35948
|
+
else if (sameTypeAsFirstArgument.has(name)) {
|
|
35949
|
+
const argType = this.inferFunctionInputType(inputs[0], lookup);
|
|
35950
|
+
if (argType instanceof basic_1.CharacterType || argType instanceof basic_1.StringType) {
|
|
35951
|
+
return argType;
|
|
35952
|
+
}
|
|
35953
|
+
return undefined;
|
|
35954
|
+
}
|
|
35955
|
+
return undefined;
|
|
35956
|
+
}
|
|
35957
|
+
static inferFunctionInputType(input, lookup) {
|
|
35958
|
+
const children = input.getChildren();
|
|
35959
|
+
if (children.length !== 1 || !(children[0] instanceof nodes_1.ExpressionNode)) {
|
|
35960
|
+
return undefined;
|
|
35961
|
+
}
|
|
35962
|
+
const child = children[0];
|
|
35963
|
+
if (child.get() instanceof Expressions.SQLFieldName || child.get() instanceof Expressions.SQLAliasField) {
|
|
35964
|
+
return lookup(child.concatTokens().toUpperCase());
|
|
35965
|
+
}
|
|
35966
|
+
else if (child.get() instanceof Expressions.SQLFunction) {
|
|
35967
|
+
return this.inferFunctionType(child, lookup);
|
|
35968
|
+
}
|
|
35969
|
+
return undefined;
|
|
35970
|
+
}
|
|
35875
35971
|
static buildDatabaseSourceInfos(from, dbSources) {
|
|
35876
35972
|
const fromSources = from.findAllExpressions(Expressions.SQLFromSource);
|
|
35877
35973
|
return dbSources.map((source, index) => {
|
|
@@ -35906,16 +36002,20 @@ class Select {
|
|
|
35906
36002
|
return undefined;
|
|
35907
36003
|
}
|
|
35908
36004
|
static findFields(node, input) {
|
|
35909
|
-
var _a, _b;
|
|
35910
|
-
|
|
36005
|
+
var _a, _b, _c;
|
|
36006
|
+
let expr = node.findFirstExpression(Expressions.SQLFieldList);
|
|
36007
|
+
// a single field can be wrapped in a nested SQLFieldList
|
|
36008
|
+
while (expr && expr.getChildren().length === 1 && ((_a = expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SQLFieldList) {
|
|
36009
|
+
expr = expr.getFirstChild();
|
|
36010
|
+
}
|
|
35911
36011
|
const ret = [];
|
|
35912
|
-
if (((
|
|
36012
|
+
if (((_b = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _b === void 0 ? void 0 : _b.get()) instanceof Expressions.Dynamic) {
|
|
35913
36013
|
dynamic_1.Dynamic.runSyntax(expr.getFirstChild(), input);
|
|
35914
36014
|
}
|
|
35915
36015
|
// eslint-disable-next-line max-len
|
|
35916
36016
|
for (const field of (expr === null || expr === void 0 ? void 0 : expr.findDirectExpressionsMulti([Expressions.SQLField, Expressions.SQLFieldName, Expressions.SQLAggregation])) || []) {
|
|
35917
36017
|
let code = field.concatTokens().toUpperCase();
|
|
35918
|
-
const as = ((
|
|
36018
|
+
const as = ((_c = field.findDirectExpression(Expressions.SQLAsName)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
|
|
35919
36019
|
if (as !== "") {
|
|
35920
36020
|
code = code.replace(" AS " + as.toUpperCase(), "");
|
|
35921
36021
|
}
|
|
@@ -72176,9 +72276,19 @@ class View extends _abstract_object_1.AbstractObject {
|
|
|
72176
72276
|
continue;
|
|
72177
72277
|
}
|
|
72178
72278
|
else if (this.parsedData.header.VIEWCLASS === ViewClass.ExternalView) {
|
|
72279
|
+
// for external views TABNAME is the view itself, the types are given directly in the xml
|
|
72280
|
+
let type = Types.VoidType.get("ExternalView");
|
|
72281
|
+
if (field.EXVDATATYPE !== undefined) {
|
|
72282
|
+
type = ddic.textToType({
|
|
72283
|
+
text: field.EXVDATATYPE,
|
|
72284
|
+
length: field.EXVFLENGTH,
|
|
72285
|
+
decimals: field.EXVDECIMALS,
|
|
72286
|
+
infoText: this.getName() + "-" + field.VIEWFIELD,
|
|
72287
|
+
});
|
|
72288
|
+
}
|
|
72179
72289
|
components.push({
|
|
72180
72290
|
name: field.VIEWFIELD,
|
|
72181
|
-
type:
|
|
72291
|
+
type: type
|
|
72182
72292
|
});
|
|
72183
72293
|
continue;
|
|
72184
72294
|
}
|
|
@@ -72266,6 +72376,9 @@ class View extends _abstract_object_1.AbstractObject {
|
|
|
72266
72376
|
TABNAME: field.TABNAME,
|
|
72267
72377
|
FIELDNAME: field.FIELDNAME,
|
|
72268
72378
|
KEYFLAG: field.KEYFLAG,
|
|
72379
|
+
EXVDATATYPE: typeof field.EXVDATATYPE === "string" && field.EXVDATATYPE !== "" ? field.EXVDATATYPE : undefined,
|
|
72380
|
+
EXVFLENGTH: typeof field.EXVFLENGTH === "string" ? field.EXVFLENGTH : undefined,
|
|
72381
|
+
EXVDECIMALS: typeof field.EXVDECIMALS === "string" ? field.EXVDECIMALS : undefined,
|
|
72269
72382
|
});
|
|
72270
72383
|
}
|
|
72271
72384
|
const join = (_j = (_h = (_g = parsed === null || parsed === void 0 ? void 0 : parsed.abapGit) === null || _g === void 0 ? void 0 : _g["asx:abap"]) === null || _h === void 0 ? void 0 : _h["asx:values"]) === null || _j === void 0 ? void 0 : _j.DD28J_TABLE;
|
|
@@ -73117,7 +73230,7 @@ class Registry {
|
|
|
73117
73230
|
}
|
|
73118
73231
|
static abaplintVersion() {
|
|
73119
73232
|
// magic, see build script "version.js"
|
|
73120
|
-
return "2.120.
|
|
73233
|
+
return "2.120.100";
|
|
73121
73234
|
}
|
|
73122
73235
|
getDDICReferences() {
|
|
73123
73236
|
return this.ddicReferences;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abaplint/cli",
|
|
3
|
-
"version": "2.120.
|
|
3
|
+
"version": "2.120.100",
|
|
4
4
|
"description": "abaplint - Command Line Interface",
|
|
5
5
|
"funding": "https://github.com/sponsors/larshp",
|
|
6
6
|
"bin": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
},
|
|
40
40
|
"homepage": "https://abaplint.org",
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@abaplint/core": "^2.120.
|
|
42
|
+
"@abaplint/core": "^2.120.100",
|
|
43
43
|
"@types/chai": "^4.3.20",
|
|
44
44
|
"@types/minimist": "^1.2.5",
|
|
45
45
|
"@types/mocha": "^10.0.10",
|