@abaplint/transpiler-cli 2.14.26 → 2.14.28

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.
Files changed (3) hide show
  1. package/build/bundle.js +417 -85
  2. package/package.json +3 -3
  3. package/schema.json +104 -97
package/build/bundle.js CHANGED
@@ -36603,6 +36603,7 @@ var __importStar = (this && this.__importStar) || (function () {
36603
36603
  Object.defineProperty(exports, "__esModule", ({ value: true }));
36604
36604
  exports.Select = void 0;
36605
36605
  const Expressions = __importStar(__webpack_require__(/*! ../../2_statements/expressions */ "./node_modules/@abaplint/core/build/src/abap/2_statements/expressions/index.js"));
36606
+ const nodes_1 = __webpack_require__(/*! ../../nodes */ "./node_modules/@abaplint/core/build/src/abap/nodes/index.js");
36606
36607
  const basic_1 = __webpack_require__(/*! ../../types/basic */ "./node_modules/@abaplint/core/build/src/abap/types/basic/index.js");
36607
36608
  const inline_data_1 = __webpack_require__(/*! ./inline_data */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/inline_data.js");
36608
36609
  const target_1 = __webpack_require__(/*! ./target */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/target.js");
@@ -36618,6 +36619,8 @@ const _syntax_input_1 = __webpack_require__(/*! ../_syntax_input */ "./node_modu
36618
36619
  const version_1 = __webpack_require__(/*! ../../../version */ "./node_modules/@abaplint/core/build/src/version.js");
36619
36620
  const _check_database_fields_1 = __webpack_require__(/*! ./_check_database_fields */ "./node_modules/@abaplint/core/build/src/abap/5_syntax/expressions/_check_database_fields.js");
36620
36621
  const isSimple = /^\w+$/;
36622
+ // SQL functions where the result has the same type as the first argument
36623
+ const sameTypeAsFirstArgument = new Set(["UPPER", "LOWER", "LTRIM", "RTRIM"]);
36621
36624
  class Select {
36622
36625
  static runSyntax(node, input, skipImplicitInto = false, selectLoop = false) {
36623
36626
  var _a;
@@ -36823,7 +36826,7 @@ class Select {
36823
36826
  if (intoStructure) {
36824
36827
  const inlineList = intoStructure.findAllExpressions(Expressions.InlineData);
36825
36828
  if (inlineList.length === 1) {
36826
- inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope));
36829
+ inline_data_1.InlineData.runSyntax(inlineList[0], input, this.buildStructureType(fields, dbSources, input.scope, from));
36827
36830
  }
36828
36831
  else {
36829
36832
  for (const inline of inlineList) {
@@ -36853,7 +36856,12 @@ class Select {
36853
36856
  return;
36854
36857
  }
36855
36858
  let type = basic_1.VoidType.get("SELECT_todo2");
36856
- if (isSimple.test(field.code)) {
36859
+ const fn = this.findFunctionColumn(field, false);
36860
+ if (fn) {
36861
+ const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
36862
+ type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, input.scope)) || type;
36863
+ }
36864
+ else if (isSimple.test(field.code)) {
36857
36865
  for (const dbSource of dbSources) {
36858
36866
  if (dbSource === undefined) {
36859
36867
  continue;
@@ -36885,7 +36893,7 @@ class Select {
36885
36893
  return basic_1.IntegerType.get();
36886
36894
  }
36887
36895
  }
36888
- static buildStructureType(fields, dbSources, scope) {
36896
+ static buildStructureType(fields, dbSources, scope, from) {
36889
36897
  var _a, _b, _c, _d, _e, _f;
36890
36898
  if (fields.length === 1 && dbSources.length === 1) {
36891
36899
  // COUNT( * ) yields an integer regardless of the (possibly dynamic) table
@@ -36921,10 +36929,16 @@ class Select {
36921
36929
  return basic_1.IntegerType.get();
36922
36930
  }
36923
36931
  }
36924
- else {
36925
- // todo: aggregated/calculated values
36926
- return basic_1.VoidType.get("SELECT_todo11");
36932
+ const fn = this.findFunctionColumn(fields[0], false);
36933
+ if (fn) {
36934
+ const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
36935
+ const type = this.inferFunctionType(fn, code => this.findFieldType(code, sourceInfos, scope));
36936
+ if (type) {
36937
+ return type;
36938
+ }
36927
36939
  }
36940
+ // todo: aggregated/calculated values
36941
+ return basic_1.VoidType.get("SELECT_todo11");
36928
36942
  }
36929
36943
  else {
36930
36944
  return basic_1.VoidType.get("SELECT_todo10");
@@ -36945,15 +36959,10 @@ class Select {
36945
36959
  if (!(dbType instanceof basic_1.StructureType)) {
36946
36960
  return basic_1.VoidType.get("SELECT_todo14");
36947
36961
  }
36948
- const allFieldsSimple = fields.every(f => isSimple.test(f.code));
36949
- if (allFieldsSimple === true) {
36950
- const components = [];
36951
- for (const field of fields) {
36952
- const type = dbType.getComponentByName(field.code);
36953
- if (type === undefined) {
36954
- return basic_1.VoidType.get("SELECT_todo9");
36955
- }
36956
- components.push({ name: field.as || field.code, type });
36962
+ if (this.allFieldsSupported(fields) === true) {
36963
+ const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
36964
+ if (components === undefined) {
36965
+ return basic_1.VoidType.get("SELECT_todo9");
36957
36966
  }
36958
36967
  return new basic_1.StructureType(components);
36959
36968
  }
@@ -36979,9 +36988,15 @@ class Select {
36979
36988
  }
36980
36989
  return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
36981
36990
  }
36991
+ const lookup = code => this.findFieldType(code, sourceInfos, scope);
36982
36992
  const components = [];
36983
36993
  for (const field of fields) {
36984
- const type = this.findFieldType(field.code, sourceInfos, scope);
36994
+ const fn = this.findFunctionColumn(field);
36995
+ if (fn) {
36996
+ components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
36997
+ continue;
36998
+ }
36999
+ const type = lookup(field.code);
36985
37000
  if (type === undefined) {
36986
37001
  return basic_1.VoidType.get("SELECT_todo3");
36987
37002
  }
@@ -37004,20 +37019,101 @@ class Select {
37004
37019
  if (fields.length === 1 && fields[0].code === "*") {
37005
37020
  return new basic_1.TableType(dbType, tableOptions, undefined);
37006
37021
  }
37007
- const allFieldsSimple = fields.every(f => isSimple.test(f.code));
37008
- if (allFieldsSimple === true) {
37009
- const components = [];
37010
- for (const field of fields) {
37011
- const type = dbType.getComponentByName(field.code);
37012
- if (type === undefined) {
37013
- return basic_1.VoidType.get("SELECT_todo6");
37014
- }
37015
- components.push({ name: field.as || field.code, type });
37022
+ if (this.allFieldsSupported(fields) === true) {
37023
+ const components = this.buildSingleSourceComponents(fields, dbType, from, dbSources, scope);
37024
+ if (components === undefined) {
37025
+ return basic_1.VoidType.get("SELECT_todo6");
37016
37026
  }
37017
37027
  return new basic_1.TableType(new basic_1.StructureType(components), tableOptions, undefined);
37018
37028
  }
37019
37029
  return basic_1.VoidType.get("SELECT_todo7");
37020
37030
  }
37031
+ /** plain field names, or SQL function columns with an alias */
37032
+ static allFieldsSupported(fields) {
37033
+ return fields.every(f => isSimple.test(f.code) || this.findFunctionColumn(f) !== undefined);
37034
+ }
37035
+ /** returns undefined if a plain field is not found in the database table */
37036
+ static buildSingleSourceComponents(fields, dbType, from, dbSources, scope) {
37037
+ const sourceInfos = this.buildDatabaseSourceInfos(from, dbSources);
37038
+ const lookup = code => this.findFieldType(code, sourceInfos, scope);
37039
+ const components = [];
37040
+ for (const field of fields) {
37041
+ const fn = this.findFunctionColumn(field);
37042
+ if (fn) {
37043
+ components.push({ name: field.as, type: this.inferFunctionType(fn, lookup) || basic_1.VoidType.get("SELECT_function") });
37044
+ continue;
37045
+ }
37046
+ const type = dbType.getComponentByName(field.code);
37047
+ if (type === undefined) {
37048
+ return undefined;
37049
+ }
37050
+ components.push({ name: field.as || field.code, type });
37051
+ }
37052
+ return components;
37053
+ }
37054
+ /** returns the SQLFunction node if the field list entry is a single SQL function call */
37055
+ static findFunctionColumn(field, requireAlias = true) {
37056
+ if (requireAlias === true && field.as === "") {
37057
+ return undefined;
37058
+ }
37059
+ else if (!(field.expression.get() instanceof Expressions.SQLField)) {
37060
+ return undefined;
37061
+ }
37062
+ const children = field.expression.getChildren().filter(c => !(c.get() instanceof Expressions.SQLAsName) && c.concatTokens().toUpperCase() !== "AS");
37063
+ if (children.length === 1
37064
+ && children[0] instanceof nodes_1.ExpressionNode
37065
+ && children[0].get() instanceof Expressions.SQLFunction) {
37066
+ return children[0];
37067
+ }
37068
+ return undefined;
37069
+ }
37070
+ /** infers the result type of a SQL function, returns undefined if not possible */
37071
+ static inferFunctionType(fn, lookup) {
37072
+ const name = fn.getFirstToken().getStr().toUpperCase();
37073
+ const inputs = fn.findDirectExpressions(Expressions.SQLFunctionInput);
37074
+ if (inputs.length === 0) {
37075
+ return undefined;
37076
+ }
37077
+ if (name === "SUBSTRING" && inputs.length === 3) {
37078
+ const len = inputs[2].concatTokens();
37079
+ if (/^\d+$/.test(len) === false || parseInt(len, 10) <= 0) {
37080
+ return undefined;
37081
+ }
37082
+ const argType = this.inferFunctionInputType(inputs[0], lookup);
37083
+ if (argType instanceof basic_1.StringType) {
37084
+ return argType;
37085
+ }
37086
+ else if (argType instanceof basic_1.CharacterType
37087
+ || argType instanceof basic_1.NumericType
37088
+ || argType instanceof basic_1.DateType
37089
+ || argType instanceof basic_1.TimeType) {
37090
+ return new basic_1.CharacterType(parseInt(len, 10));
37091
+ }
37092
+ return undefined;
37093
+ }
37094
+ else if (sameTypeAsFirstArgument.has(name)) {
37095
+ const argType = this.inferFunctionInputType(inputs[0], lookup);
37096
+ if (argType instanceof basic_1.CharacterType || argType instanceof basic_1.StringType) {
37097
+ return argType;
37098
+ }
37099
+ return undefined;
37100
+ }
37101
+ return undefined;
37102
+ }
37103
+ static inferFunctionInputType(input, lookup) {
37104
+ const children = input.getChildren();
37105
+ if (children.length !== 1 || !(children[0] instanceof nodes_1.ExpressionNode)) {
37106
+ return undefined;
37107
+ }
37108
+ const child = children[0];
37109
+ if (child.get() instanceof Expressions.SQLFieldName || child.get() instanceof Expressions.SQLAliasField) {
37110
+ return lookup(child.concatTokens().toUpperCase());
37111
+ }
37112
+ else if (child.get() instanceof Expressions.SQLFunction) {
37113
+ return this.inferFunctionType(child, lookup);
37114
+ }
37115
+ return undefined;
37116
+ }
37021
37117
  static buildDatabaseSourceInfos(from, dbSources) {
37022
37118
  const fromSources = from.findAllExpressions(Expressions.SQLFromSource);
37023
37119
  return dbSources.map((source, index) => {
@@ -37052,16 +37148,20 @@ class Select {
37052
37148
  return undefined;
37053
37149
  }
37054
37150
  static findFields(node, input) {
37055
- var _a, _b;
37056
- const expr = node.findFirstExpression(Expressions.SQLFieldList);
37151
+ var _a, _b, _c;
37152
+ let expr = node.findFirstExpression(Expressions.SQLFieldList);
37153
+ // a single field can be wrapped in a nested SQLFieldList
37154
+ while (expr && expr.getChildren().length === 1 && ((_a = expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.SQLFieldList) {
37155
+ expr = expr.getFirstChild();
37156
+ }
37057
37157
  const ret = [];
37058
- if (((_a = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _a === void 0 ? void 0 : _a.get()) instanceof Expressions.Dynamic) {
37158
+ if (((_b = expr === null || expr === void 0 ? void 0 : expr.getFirstChild()) === null || _b === void 0 ? void 0 : _b.get()) instanceof Expressions.Dynamic) {
37059
37159
  dynamic_1.Dynamic.runSyntax(expr.getFirstChild(), input);
37060
37160
  }
37061
37161
  // eslint-disable-next-line max-len
37062
37162
  for (const field of (expr === null || expr === void 0 ? void 0 : expr.findDirectExpressionsMulti([Expressions.SQLField, Expressions.SQLFieldName, Expressions.SQLAggregation])) || []) {
37063
37163
  let code = field.concatTokens().toUpperCase();
37064
- const as = ((_b = field.findDirectExpression(Expressions.SQLAsName)) === null || _b === void 0 ? void 0 : _b.concatTokens()) || "";
37164
+ const as = ((_c = field.findDirectExpression(Expressions.SQLAsName)) === null || _c === void 0 ? void 0 : _c.concatTokens()) || "";
37065
37165
  if (as !== "") {
37066
37166
  code = code.replace(" AS " + as.toUpperCase(), "");
37067
37167
  }
@@ -73322,9 +73422,19 @@ class View extends _abstract_object_1.AbstractObject {
73322
73422
  continue;
73323
73423
  }
73324
73424
  else if (this.parsedData.header.VIEWCLASS === ViewClass.ExternalView) {
73425
+ // for external views TABNAME is the view itself, the types are given directly in the xml
73426
+ let type = Types.VoidType.get("ExternalView");
73427
+ if (field.EXVDATATYPE !== undefined) {
73428
+ type = ddic.textToType({
73429
+ text: field.EXVDATATYPE,
73430
+ length: field.EXVFLENGTH,
73431
+ decimals: field.EXVDECIMALS,
73432
+ infoText: this.getName() + "-" + field.VIEWFIELD,
73433
+ });
73434
+ }
73325
73435
  components.push({
73326
73436
  name: field.VIEWFIELD,
73327
- type: Types.VoidType.get("ExternalView")
73437
+ type: type
73328
73438
  });
73329
73439
  continue;
73330
73440
  }
@@ -73412,6 +73522,9 @@ class View extends _abstract_object_1.AbstractObject {
73412
73522
  TABNAME: field.TABNAME,
73413
73523
  FIELDNAME: field.FIELDNAME,
73414
73524
  KEYFLAG: field.KEYFLAG,
73525
+ EXVDATATYPE: typeof field.EXVDATATYPE === "string" && field.EXVDATATYPE !== "" ? field.EXVDATATYPE : undefined,
73526
+ EXVFLENGTH: typeof field.EXVFLENGTH === "string" ? field.EXVFLENGTH : undefined,
73527
+ EXVDECIMALS: typeof field.EXVDECIMALS === "string" ? field.EXVDECIMALS : undefined,
73415
73528
  });
73416
73529
  }
73417
73530
  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;
@@ -74263,7 +74376,7 @@ class Registry {
74263
74376
  }
74264
74377
  static abaplintVersion() {
74265
74378
  // magic, see build script "version.js"
74266
- return "2.120.98";
74379
+ return "2.120.100";
74267
74380
  }
74268
74381
  getDDICReferences() {
74269
74382
  return this.ddicReferences;
@@ -117229,6 +117342,70 @@ function packedTypeToDatabase(type) {
117229
117342
 
117230
117343
  /***/ },
117231
117344
 
117345
+ /***/ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/external_view.js"
117346
+ /*!*******************************************************************************************!*\
117347
+ !*** ./node_modules/@abaplint/transpiler/build/src/db/schema_generation/external_view.js ***!
117348
+ \*******************************************************************************************/
117349
+ (__unused_webpack_module, exports, __webpack_require__) {
117350
+
117351
+ "use strict";
117352
+
117353
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
117354
+ if (k2 === undefined) k2 = k;
117355
+ var desc = Object.getOwnPropertyDescriptor(m, k);
117356
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
117357
+ desc = { enumerable: true, get: function() { return m[k]; } };
117358
+ }
117359
+ Object.defineProperty(o, k2, desc);
117360
+ }) : (function(o, m, k, k2) {
117361
+ if (k2 === undefined) k2 = k;
117362
+ o[k2] = m[k];
117363
+ }));
117364
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
117365
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
117366
+ }) : function(o, v) {
117367
+ o["default"] = v;
117368
+ });
117369
+ var __importStar = (this && this.__importStar) || (function () {
117370
+ var ownKeys = function(o) {
117371
+ ownKeys = Object.getOwnPropertyNames || function (o) {
117372
+ var ar = [];
117373
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
117374
+ return ar;
117375
+ };
117376
+ return ownKeys(o);
117377
+ };
117378
+ return function (mod) {
117379
+ if (mod && mod.__esModule) return mod;
117380
+ var result = {};
117381
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
117382
+ __setModuleDefault(result, mod);
117383
+ return result;
117384
+ };
117385
+ })();
117386
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
117387
+ exports.ExternalView = void 0;
117388
+ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
117389
+ /** External view, VIEWCLASS X: a DDIC view on a HANA view, eg. a calculation view. Its definition lives
117390
+ * in HANA, so locally it becomes a table with the declared columns which tests can fill with data */
117391
+ class ExternalView {
117392
+ static isExternal(view) {
117393
+ return /<VIEWCLASS>X<\/VIEWCLASS>/.test(view.getXMLFile()?.getRaw() || "");
117394
+ }
117395
+ static columns(view, reg) {
117396
+ const type = view.parseType(reg);
117397
+ if (!(type instanceof abaplint.BasicTypes.StructureType)) {
117398
+ throw new Error(`External view ${view.getName()}: no fields`);
117399
+ }
117400
+ // the field types come from EXVDATATYPE, abaplint types the fields void if it is missing
117401
+ return { columns: [...type.getComponents()], keys: view.listKeys() };
117402
+ }
117403
+ }
117404
+ exports.ExternalView = ExternalView;
117405
+ //# sourceMappingURL=external_view.js.map
117406
+
117407
+ /***/ },
117408
+
117232
117409
  /***/ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/pg_database_schema.js"
117233
117410
  /*!************************************************************************************************!*\
117234
117411
  !*** ./node_modules/@abaplint/transpiler/build/src/db/schema_generation/pg_database_schema.js ***!
@@ -117273,6 +117450,7 @@ var __importStar = (this && this.__importStar) || (function () {
117273
117450
  Object.defineProperty(exports, "__esModule", ({ value: true }));
117274
117451
  exports.PGDatabaseSchema = void 0;
117275
117452
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
117453
+ const external_view_1 = __webpack_require__(/*! ./external_view */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/external_view.js");
117276
117454
  const database_schema_generator_1 = __webpack_require__(/*! ./database_schema_generator */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/database_schema_generator.js");
117277
117455
  const _database_schema_reuse_1 = __webpack_require__(/*! ./_database_schema_reuse */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/_database_schema_reuse.js");
117278
117456
  const QUOTE = "\"";
@@ -117282,6 +117460,10 @@ class PGDatabaseSchema {
117282
117460
  this.reg = reg;
117283
117461
  }
117284
117462
  buildVIEW(view) {
117463
+ if (external_view_1.ExternalView.isExternal(view)) {
117464
+ const { columns, keys } = external_view_1.ExternalView.columns(view, this.reg);
117465
+ return this.createTable(view.getName(), columns, keys);
117466
+ }
117285
117467
  return new _database_schema_reuse_1.DatabaseSchemaReuse(QUOTE).buildVIEW(view);
117286
117468
  }
117287
117469
  buildTABL(tabl) {
@@ -117289,22 +117471,25 @@ class PGDatabaseSchema {
117289
117471
  if (!(type instanceof abaplint.BasicTypes.StructureType)) {
117290
117472
  return "";
117291
117473
  }
117292
- const fields = [];
117293
- const fieldsRaw = [];
117474
+ const columns = [];
117294
117475
  for (const field of type.getComponents()) {
117295
117476
  if (field.type instanceof abaplint.BasicTypes.StructureType) {
117296
117477
  // is a GROUP NAME
117297
117478
  continue;
117298
117479
  }
117299
- fieldsRaw.push(field.name.toLowerCase());
117300
- fields.push("\"" + field.name.toLowerCase() + "\" " + this.toType(field.type, field.name, tabl.getName()));
117480
+ columns.push(field);
117301
117481
  }
117302
117482
  // assumption: all transparent tables have primary keys
117303
- // add single quotes to field names to allow for keywords as field names
117304
- const key = ", PRIMARY KEY(" + tabl.listKeys(this.reg)
117483
+ return this.createTable(tabl.getName(), columns, tabl.listKeys(this.reg));
117484
+ }
117485
+ createTable(name, columns, keys) {
117486
+ const fieldsRaw = columns.map(c => c.name.toLowerCase());
117487
+ // quote field names to allow for keywords as field names
117488
+ const fields = columns.map(c => "\"" + c.name.toLowerCase() + "\" " + this.toType(c.type, c.name, name));
117489
+ const key = ", PRIMARY KEY(" + keys
117305
117490
  .filter(e => fieldsRaw.includes(e.toLowerCase()))
117306
117491
  .map(e => "\"" + e.toLowerCase() + "\"").join(",") + ")";
117307
- return `CREATE TABLE "${tabl.getName().toLowerCase()}" (${fields.join(", ")}${key});\n`;
117492
+ return `CREATE TABLE "${name.toLowerCase()}" (${fields.join(", ")}${key});\n`;
117308
117493
  }
117309
117494
  toType(type, fieldname, errorInfo) {
117310
117495
  if (type instanceof abaplint.BasicTypes.CharacterType) {
@@ -117400,13 +117585,18 @@ var __importStar = (this && this.__importStar) || (function () {
117400
117585
  Object.defineProperty(exports, "__esModule", ({ value: true }));
117401
117586
  exports.SnowflakeDatabaseSchema = void 0;
117402
117587
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
117588
+ const external_view_1 = __webpack_require__(/*! ./external_view */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/external_view.js");
117403
117589
  const database_schema_generator_1 = __webpack_require__(/*! ./database_schema_generator */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/database_schema_generator.js");
117404
117590
  class SnowflakeDatabaseSchema {
117405
117591
  reg;
117406
117592
  constructor(reg) {
117407
117593
  this.reg = reg;
117408
117594
  }
117409
- buildVIEW(_view) {
117595
+ buildVIEW(view) {
117596
+ if (external_view_1.ExternalView.isExternal(view)) {
117597
+ const { columns, keys } = external_view_1.ExternalView.columns(view, this.reg);
117598
+ return this.createTable(view.getName(), columns, keys);
117599
+ }
117410
117600
  return "Error: buildView, todo snowflake";
117411
117601
  }
117412
117602
  buildTABL(tabl) {
@@ -117414,22 +117604,25 @@ class SnowflakeDatabaseSchema {
117414
117604
  if (!(type instanceof abaplint.BasicTypes.StructureType)) {
117415
117605
  return "";
117416
117606
  }
117417
- const fields = [];
117418
- const fieldsRaw = [];
117607
+ const columns = [];
117419
117608
  for (const field of type.getComponents()) {
117420
117609
  if (field.type instanceof abaplint.BasicTypes.StructureType) {
117421
117610
  // is a GROUP NAME
117422
117611
  continue;
117423
117612
  }
117424
- fieldsRaw.push(field.name.toLowerCase());
117425
- fields.push("\"" + field.name.toLowerCase() + "\" " + this.toType(field.type, field.name, tabl.getName()));
117613
+ columns.push(field);
117426
117614
  }
117427
117615
  // assumption: all transparent tables have primary keys
117428
- // add single quotes to field names to allow for keywords as field names
117429
- const key = ", PRIMARY KEY(" + tabl.listKeys(this.reg)
117616
+ return this.createTable(tabl.getName(), columns, tabl.listKeys(this.reg));
117617
+ }
117618
+ createTable(name, columns, keys) {
117619
+ const fieldsRaw = columns.map(c => c.name.toLowerCase());
117620
+ // quote field names to allow for keywords as field names
117621
+ const fields = columns.map(c => "\"" + c.name.toLowerCase() + "\" " + this.toType(c.type, c.name, name));
117622
+ const key = ", PRIMARY KEY(" + keys
117430
117623
  .filter(e => fieldsRaw.includes(e.toLowerCase()))
117431
117624
  .map(e => "\"" + e.toLowerCase() + "\"").join(",") + ")";
117432
- return `CREATE TABLE "${tabl.getName().toLowerCase()}" (${fields.join(", ")}${key});\n`;
117625
+ return `CREATE TABLE "${name.toLowerCase()}" (${fields.join(", ")}${key});\n`;
117433
117626
  }
117434
117627
  // https://docs.snowflake.com/en/sql-reference/collation
117435
117628
  toType(type, fieldname, errorInfo) {
@@ -117526,6 +117719,7 @@ var __importStar = (this && this.__importStar) || (function () {
117526
117719
  Object.defineProperty(exports, "__esModule", ({ value: true }));
117527
117720
  exports.SQLiteDatabaseSchema = void 0;
117528
117721
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
117722
+ const external_view_1 = __webpack_require__(/*! ./external_view */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/external_view.js");
117529
117723
  const database_schema_generator_1 = __webpack_require__(/*! ./database_schema_generator */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/database_schema_generator.js");
117530
117724
  const _database_schema_reuse_1 = __webpack_require__(/*! ./_database_schema_reuse */ "./node_modules/@abaplint/transpiler/build/src/db/schema_generation/_database_schema_reuse.js");
117531
117725
  const QUOTE = "'";
@@ -117536,6 +117730,10 @@ class SQLiteDatabaseSchema {
117536
117730
  }
117537
117731
  // https://www.sqlite.org/lang_createview.html
117538
117732
  buildVIEW(view) {
117733
+ if (external_view_1.ExternalView.isExternal(view)) {
117734
+ const { columns, keys } = external_view_1.ExternalView.columns(view, this.reg);
117735
+ return this.createTable(view.getName(), columns, keys);
117736
+ }
117539
117737
  return new _database_schema_reuse_1.DatabaseSchemaReuse(QUOTE).buildVIEW(view);
117540
117738
  }
117541
117739
  buildTABL(tabl) {
@@ -117543,22 +117741,25 @@ class SQLiteDatabaseSchema {
117543
117741
  if (!(type instanceof abaplint.BasicTypes.StructureType)) {
117544
117742
  return "";
117545
117743
  }
117546
- const fields = [];
117547
- const fieldsRaw = [];
117744
+ const columns = [];
117548
117745
  for (const field of type.getComponents()) {
117549
117746
  if (field.type instanceof abaplint.BasicTypes.StructureType) {
117550
117747
  // is a GROUP NAME
117551
117748
  continue;
117552
117749
  }
117553
- fieldsRaw.push(field.name.toLowerCase());
117554
- fields.push("'" + field.name.toLowerCase() + "' " + this.toType(field.type, field.name, tabl.getName()));
117750
+ columns.push(field);
117555
117751
  }
117556
117752
  // assumption: all transparent tables have primary keys
117557
- // add single quotes to field names to allow for keywords as field names
117558
- const key = ", PRIMARY KEY(" + tabl.listKeys(this.reg)
117753
+ return this.createTable(tabl.getName(), columns, tabl.listKeys(this.reg));
117754
+ }
117755
+ createTable(name, columns, keys) {
117756
+ const fieldsRaw = columns.map(c => c.name.toLowerCase());
117757
+ // quote field names to allow for keywords as field names
117758
+ const fields = columns.map(c => "'" + c.name.toLowerCase() + "' " + this.toType(c.type, c.name, name));
117759
+ const key = ", PRIMARY KEY(" + keys
117559
117760
  .filter(e => fieldsRaw.includes(e.toLowerCase()))
117560
117761
  .map(e => "'" + e.toLowerCase() + "'").join(",") + ")";
117561
- return `CREATE TABLE '${tabl.getName().toLowerCase()}' (${fields.join(", ")}${key});\n`;
117762
+ return `CREATE TABLE '${name.toLowerCase()}' (${fields.join(", ")}${key});\n`;
117562
117763
  }
117563
117764
  toType(type, fieldname, errorInfo) {
117564
117765
  if (type instanceof abaplint.BasicTypes.CharacterType) {
@@ -117835,6 +118036,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
117835
118036
  exports.CallTransformationOptionsTranspiler = void 0;
117836
118037
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
117837
118038
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
118039
+ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
117838
118040
  class CallTransformationOptionsTranspiler {
117839
118041
  transpile(node, traversal) {
117840
118042
  const res = new chunk_1.Chunk().appendString("{");
@@ -117843,7 +118045,7 @@ class CallTransformationOptionsTranspiler {
117843
118045
  if (res.getCode() !== "{") {
117844
118046
  res.appendString(",");
117845
118047
  }
117846
- res.appendString(c.concatTokens());
118048
+ res.appendString(constant_1.ConstantTranspiler.normalizeInteger(c.concatTokens()));
117847
118049
  }
117848
118050
  else if (c.get() instanceof abaplint.Expressions.Source) {
117849
118051
  res.appendChunk(traversal.traverse(c));
@@ -117909,6 +118111,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
117909
118111
  exports.CallTransformationParametersTranspiler = void 0;
117910
118112
  const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
117911
118113
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
118114
+ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
117912
118115
  class CallTransformationParametersTranspiler {
117913
118116
  transpile(node, traversal) {
117914
118117
  if (node.getFirstChild()?.get() instanceof abaplint.Expressions.Dynamic) {
@@ -117921,7 +118124,7 @@ class CallTransformationParametersTranspiler {
117921
118124
  if (res.getCode() !== "{") {
117922
118125
  res.appendString(",");
117923
118126
  }
117924
- res.appendString(c.concatTokens());
118127
+ res.appendString(constant_1.ConstantTranspiler.normalizeInteger(c.concatTokens()));
117925
118128
  }
117926
118129
  else if (c.get() instanceof abaplint.Expressions.SimpleSource3) {
117927
118130
  res.appendChunk(traversal.traverse(c));
@@ -118683,11 +118886,20 @@ class ConstantTranspiler {
118683
118886
  constructor(addGet = false) {
118684
118887
  this.addGet = addGet;
118685
118888
  }
118686
- handleInteger(int, traversal) {
118687
- let concat = int.concatTokens().trim().replace(/^0+/, "");
118688
- if (concat === "") {
118689
- concat = "0";
118889
+ /** Normalizes an ABAP integer literal to a JavaScript decimal integer literal, which is also
118890
+ * valid in strict mode, where leading zeros give an octal literal and a SyntaxError.
118891
+ * "007" -> "7", "000" -> "0", "-007" -> "-7", "- 010" -> "-10", "+5" -> "5", "-000" -> "0".
118892
+ * Input that is not an integer literal is returned unchanged */
118893
+ static normalizeInteger(str) {
118894
+ const match = str.replace(/\s/g, "").match(/^([+-]?)(\d+)$/);
118895
+ if (match === null) {
118896
+ return str;
118690
118897
  }
118898
+ const digits = match[2].replace(/^0+(?=\d)/, "");
118899
+ return match[1] === "-" && digits !== "0" ? "-" + digits : digits;
118900
+ }
118901
+ handleInteger(int, traversal) {
118902
+ const concat = ConstantTranspiler.normalizeInteger(int.concatTokens());
118691
118903
  const parsed = Number.parseInt(concat, 10);
118692
118904
  let code = "";
118693
118905
  if (concat.length > 18) {
@@ -119237,6 +119449,7 @@ exports.FieldLengthTranspiler = void 0;
119237
119449
  const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
119238
119450
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
119239
119451
  const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
119452
+ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
119240
119453
  class FieldLengthTranspiler {
119241
119454
  transpile(node, traversal) {
119242
119455
  let ret = "";
@@ -119248,11 +119461,7 @@ class FieldLengthTranspiler {
119248
119461
  }
119249
119462
  else if (c instanceof core_1.Nodes.TokenNode) {
119250
119463
  if (c.get() instanceof core_1.Tokens.Identifier) {
119251
- let value = c.getFirstToken().getStr();
119252
- if (/^0+\d+$/.test(value)) {
119253
- value = value.replace(/^0+/, "") || "0";
119254
- }
119255
- ret += value;
119464
+ ret += constant_1.ConstantTranspiler.normalizeInteger(c.getFirstToken().getStr());
119256
119465
  }
119257
119466
  }
119258
119467
  }
@@ -119277,6 +119486,7 @@ exports.FieldOffsetTranspiler = void 0;
119277
119486
  const core_1 = __webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js");
119278
119487
  const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
119279
119488
  const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
119489
+ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
119280
119490
  class FieldOffsetTranspiler {
119281
119491
  transpile(node, traversal) {
119282
119492
  let ret = "";
@@ -119288,11 +119498,7 @@ class FieldOffsetTranspiler {
119288
119498
  }
119289
119499
  else if (c instanceof core_1.Nodes.TokenNode) {
119290
119500
  if (c.get() instanceof core_1.Tokens.Identifier) {
119291
- let value = c.getFirstToken().getStr().toLowerCase();
119292
- if (/^0+\d+$/.test(value)) {
119293
- value = value.replace(/^0+/, "") || "0";
119294
- }
119295
- ret += value;
119501
+ ret += constant_1.ConstantTranspiler.normalizeInteger(c.getFirstToken().getStr().toLowerCase());
119296
119502
  }
119297
119503
  }
119298
119504
  }
@@ -121614,8 +121820,10 @@ const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_mod
121614
121820
  const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
121615
121821
  const sql_field_name_1 = __webpack_require__(/*! ./sql_field_name */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_name.js");
121616
121822
  const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/transpiler/build/src/expressions/source.js");
121823
+ const constant_1 = __webpack_require__(/*! ./constant */ "./node_modules/@abaplint/transpiler/build/src/expressions/constant.js");
121617
121824
  const sql_field_list_1 = __webpack_require__(/*! ./sql_field_list */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_list.js");
121618
121825
  const sql_from_1 = __webpack_require__(/*! ./sql_from */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_from.js");
121826
+ const sql_function_1 = __webpack_require__(/*! ./sql_function */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_function.js");
121619
121827
  class SQLCondTranspiler {
121620
121828
  transpile(node, traversal, table) {
121621
121829
  let ret = "";
@@ -121665,18 +121873,22 @@ class SQLCondTranspiler {
121665
121873
  sqlIn(c, traversal, filename, table) {
121666
121874
  const fieldName = c.findDirectExpression(abaplint.Expressions.SQLFieldName)
121667
121875
  || c.findDirectExpression(abaplint.Expressions.SQLAliasField);
121876
+ const sqlFunction = c.getFirstChild()?.get() instanceof abaplint.Expressions.SQLFunction
121877
+ ? c.getFirstChild() : undefined;
121668
121878
  const sqlin = c.findDirectExpression(abaplint.Expressions.SQLIn);
121669
121879
  const subselect = sqlin === undefined ? undefined : this.findSubselect(sqlin);
121670
- if (fieldName === undefined || sqlin === undefined) {
121880
+ if ((fieldName === undefined && sqlFunction === undefined) || sqlin === undefined) {
121671
121881
  throw new Error("SQL Condition, transpiler todo, " + c.concatTokens());
121672
121882
  }
121883
+ const fieldCode = () => sqlFunction
121884
+ ? new sql_function_1.SQLFunctionTranspiler().transpile(sqlFunction, traversal).getCode()
121885
+ : new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
121673
121886
  let pre = "";
121674
121887
  if (c.concatTokens().toUpperCase().includes(" NOT IN ")) {
121675
121888
  pre = "NOT ";
121676
121889
  }
121677
121890
  if (subselect) {
121678
- const field = new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
121679
- return `${field} ${pre}IN ${this.sqlSubselect(subselect, traversal, table)}`;
121891
+ return `${fieldCode()} ${pre}IN ${this.sqlSubselect(subselect, traversal, table)}`;
121680
121892
  }
121681
121893
  const source = c.findFirstExpression(abaplint.Expressions.SimpleSource3);
121682
121894
  if (source === undefined) {
@@ -121684,12 +121896,15 @@ class SQLCondTranspiler {
121684
121896
  }
121685
121897
  if (sqlin.getChildren().length === 2) {
121686
121898
  const s = new source_1.SourceTranspiler().transpile(source, traversal).getCode();
121899
+ if (sqlFunction) {
121900
+ return `${pre}" + abap.expandIN("${fieldCode()}", ${s}, true) + "`;
121901
+ }
121687
121902
  return `${pre}" + abap.expandIN("${fieldName.concatTokens()}", ${s}) + "`;
121688
121903
  }
121689
121904
  else {
121690
121905
  const cond = [];
121691
121906
  for (const s of sqlin.findDirectExpressions(abaplint.Expressions.SQLSource).concat(sqlin.findDirectExpressions(abaplint.Expressions.SQLSourceNoSpace))) {
121692
- const field = new sql_field_name_1.SQLFieldNameTranspiler().transpile(fieldName, traversal).getCode();
121907
+ const field = fieldCode();
121693
121908
  const sourc = this.sqlSource(s, traversal, filename, table);
121694
121909
  cond.push(field + " = " + sourc);
121695
121910
  }
@@ -121723,6 +121938,12 @@ class SQLCondTranspiler {
121723
121938
  ret += fieldName + " IS NULL";
121724
121939
  return ret;
121725
121940
  }
121941
+ const sqlFunction = c.findDirectExpression(abaplint.Expressions.SQLFunction);
121942
+ if (sqlFunction && c.getFirstChild() === sqlFunction && operator && source) {
121943
+ return new sql_function_1.SQLFunctionTranspiler().transpile(sqlFunction, traversal).getCode() + " "
121944
+ + this.sqlOperator(operator.concatTokens()) + " "
121945
+ + this.sqlSource(source, traversal, filename, table);
121946
+ }
121726
121947
  const aggregation = c.findDirectExpression(abaplint.Expressions.SQLAggregation);
121727
121948
  if (aggregation && operator && source) {
121728
121949
  return aggregation.concatTokens() + " " + this.sqlOperator(operator.concatTokens()) + " "
@@ -121824,7 +122045,9 @@ class SQLCondTranspiler {
121824
122045
  const conversionField = traversal.isSQLConversion(source.getFirstToken());
121825
122046
  if (conversionField) {
121826
122047
  const field = (table?.parseType(traversal.reg)).getComponentByName(conversionField);
121827
- ret += "'\" + abap.sqlEscape(" + traversal.toType(field) + ".set(" + concat + ").get()) + \"'";
122048
+ // the literal is emitted as JavaScript, an integer like 007 must not become an octal literal
122049
+ const value = constant_1.ConstantTranspiler.normalizeInteger(concat);
122050
+ ret += "'\" + abap.sqlEscape(" + traversal.toType(field) + ".set(" + value + ").get()) + \"'";
121828
122051
  }
121829
122052
  else if (concat.startsWith("`")) {
121830
122053
  ret += "'" + concat.substring(1, concat.length - 1).replace(/'/g, "''") + "'";
@@ -122368,6 +122591,117 @@ exports.SQLFromSourceTranspiler = SQLFromSourceTranspiler;
122368
122591
 
122369
122592
  /***/ },
122370
122593
 
122594
+ /***/ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_function.js"
122595
+ /*!*********************************************************************************!*\
122596
+ !*** ./node_modules/@abaplint/transpiler/build/src/expressions/sql_function.js ***!
122597
+ \*********************************************************************************/
122598
+ (__unused_webpack_module, exports, __webpack_require__) {
122599
+
122600
+ "use strict";
122601
+
122602
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
122603
+ if (k2 === undefined) k2 = k;
122604
+ var desc = Object.getOwnPropertyDescriptor(m, k);
122605
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
122606
+ desc = { enumerable: true, get: function() { return m[k]; } };
122607
+ }
122608
+ Object.defineProperty(o, k2, desc);
122609
+ }) : (function(o, m, k, k2) {
122610
+ if (k2 === undefined) k2 = k;
122611
+ o[k2] = m[k];
122612
+ }));
122613
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
122614
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
122615
+ }) : function(o, v) {
122616
+ o["default"] = v;
122617
+ });
122618
+ var __importStar = (this && this.__importStar) || (function () {
122619
+ var ownKeys = function(o) {
122620
+ ownKeys = Object.getOwnPropertyNames || function (o) {
122621
+ var ar = [];
122622
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
122623
+ return ar;
122624
+ };
122625
+ return ownKeys(o);
122626
+ };
122627
+ return function (mod) {
122628
+ if (mod && mod.__esModule) return mod;
122629
+ var result = {};
122630
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
122631
+ __setModuleDefault(result, mod);
122632
+ return result;
122633
+ };
122634
+ })();
122635
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
122636
+ exports.SQLFunctionTranspiler = void 0;
122637
+ const abaplint = __importStar(__webpack_require__(/*! @abaplint/core */ "./node_modules/@abaplint/core/build/src/index.js"));
122638
+ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/transpiler/build/src/chunk.js");
122639
+ const sql_field_name_1 = __webpack_require__(/*! ./sql_field_name */ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_field_name.js");
122640
+ const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_modules/@abaplint/transpiler/build/src/expressions/simple_source3.js");
122641
+ const source_1 = __webpack_require__(/*! ./source */ "./node_modules/@abaplint/transpiler/build/src/expressions/source.js");
122642
+ /** SQL function call like substring( field, 8, 1 ), passed through by name */
122643
+ class SQLFunctionTranspiler {
122644
+ transpile(node, traversal) {
122645
+ const name = node.getFirstToken().getStr().toLowerCase();
122646
+ const inputs = node.findDirectExpressions(abaplint.Expressions.SQLFunctionInput)
122647
+ .map(i => this.input(i, traversal));
122648
+ return new chunk_1.Chunk().appendString(name + "(" + inputs.join(", ") + ")");
122649
+ }
122650
+ input(node, traversal) {
122651
+ const ret = [];
122652
+ let host = false;
122653
+ for (const c of node.getChildren()) {
122654
+ if (c instanceof abaplint.Nodes.TokenNode) {
122655
+ if (c.getFirstToken().getStr() === "@") {
122656
+ host = true;
122657
+ }
122658
+ else {
122659
+ ret.push(c.concatTokens());
122660
+ }
122661
+ continue;
122662
+ }
122663
+ const get = c.get();
122664
+ if (host && get instanceof abaplint.Expressions.SimpleSource3) {
122665
+ const code = new simple_source3_1.SimpleSource3Transpiler(true).transpile(c, traversal).getCode();
122666
+ ret.push(`'" + abap.sqlEscape(${code}) + "'`);
122667
+ host = false;
122668
+ }
122669
+ else if (host && get instanceof abaplint.Expressions.Source) {
122670
+ const code = new source_1.SourceTranspiler(true).transpile(c, traversal).getCode();
122671
+ ret.push(`'" + abap.sqlEscape(${code}) + "'`);
122672
+ host = false;
122673
+ }
122674
+ else if (get instanceof abaplint.Expressions.SQLFieldName && /^\d+$/.test(c.concatTokens())) {
122675
+ // integer literals are parsed as field names
122676
+ ret.push(c.concatTokens());
122677
+ }
122678
+ else if (get instanceof abaplint.Expressions.SQLFieldName || get instanceof abaplint.Expressions.SQLAliasField) {
122679
+ ret.push(new sql_field_name_1.SQLFieldNameTranspiler().transpile(c, traversal).getCode());
122680
+ }
122681
+ else if (get instanceof abaplint.Expressions.SQLFunction) {
122682
+ ret.push(this.transpile(c, traversal).getCode());
122683
+ }
122684
+ else if (get instanceof abaplint.Expressions.SQLFunctionInput) {
122685
+ ret.push(this.input(c, traversal));
122686
+ }
122687
+ else {
122688
+ const concat = c.concatTokens();
122689
+ if (concat.startsWith("`")) {
122690
+ ret.push("'" + concat.substring(1, concat.length - 1).replace(/'/g, "''") + "'");
122691
+ }
122692
+ else {
122693
+ ret.push(concat);
122694
+ }
122695
+ }
122696
+ }
122697
+ return ret.join(" ").replace(/\( /g, "(").replace(/ \)/g, ")");
122698
+ }
122699
+ }
122700
+ exports.SQLFunctionTranspiler = SQLFunctionTranspiler;
122701
+ //# sourceMappingURL=sql_function.js.map
122702
+
122703
+ /***/ },
122704
+
122371
122705
  /***/ "./node_modules/@abaplint/transpiler/build/src/expressions/sql_group_by.js"
122372
122706
  /*!*********************************************************************************!*\
122373
122707
  !*** ./node_modules/@abaplint/transpiler/build/src/expressions/sql_group_by.js ***!
@@ -126915,14 +127249,11 @@ switch (e.classic.toUpperCase()) {\n`;
126915
127249
  for (const e of node.findAllExpressions(abaplint.Expressions.ParameterException)) {
126916
127250
  const name = e.getFirstToken().getStr().toUpperCase();
126917
127251
  // todo, also handle SimpleChain,
126918
- let value = e.findFirstExpression(abaplint.Expressions.Integer)?.getFirstToken().getStr().toUpperCase();
126919
- if (value === undefined) {
127252
+ const integer = e.findFirstExpression(abaplint.Expressions.Integer);
127253
+ if (integer === undefined) {
126920
127254
  continue;
126921
127255
  }
126922
- while (value.substring(0, 1) === "0" && value.length > 1) {
126923
- // remove leading zeros
126924
- value = value.substring(1);
126925
- }
127256
+ const value = expressions_1.ConstantTranspiler.normalizeInteger(integer.concatTokens());
126926
127257
  if (name === "OTHERS") {
126927
127258
  post += `default: abap.builtin.sy.get().subrc.set(${value}); break;\n`;
126928
127259
  }
@@ -128697,12 +129028,13 @@ class DataTranspiler {
128697
129028
  let value = "";
128698
129029
  const val = node.findFirstExpression(abaplint.Expressions.Value);
128699
129030
  if (val) {
128700
- let int = val.findFirstExpression(abaplint.Expressions.Integer);
128701
- if (int === undefined) {
128702
- int = val.findFirstExpression(abaplint.Expressions.ConstantString);
128703
- }
129031
+ const int = val.findFirstExpression(abaplint.Expressions.Integer);
129032
+ const str = val.findFirstExpression(abaplint.Expressions.ConstantString);
128704
129033
  if (int) {
128705
- const escaped = constant_1.ConstantTranspiler.escape(constant_1.ConstantTranspiler.trimTextFieldLiteral(int.concatTokens()));
129034
+ value = "\n" + name + ".set(" + constant_1.ConstantTranspiler.normalizeInteger(int.concatTokens()) + ");";
129035
+ }
129036
+ else if (str) {
129037
+ const escaped = constant_1.ConstantTranspiler.escape(constant_1.ConstantTranspiler.trimTextFieldLiteral(str.concatTokens()));
128706
129038
  value = "\n" + name + ".set(" + escaped + ");";
128707
129039
  }
128708
129040
  else if (val.getChildren()[1].get() instanceof abaplint.Expressions.SimpleFieldChain) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.14.26",
3
+ "version": "2.14.28",
4
4
  "description": "Transpiler - Command Line Interface",
5
5
  "funding": "https://github.com/sponsors/larshp",
6
6
  "bin": {
@@ -27,8 +27,8 @@
27
27
  "author": "abaplint",
28
28
  "license": "MIT",
29
29
  "devDependencies": {
30
- "@abaplint/core": "^2.120.98",
31
- "@abaplint/transpiler": "^2.14.26",
30
+ "@abaplint/core": "^2.120.100",
31
+ "@abaplint/transpiler": "^2.14.28",
32
32
  "@types/glob": "^9.0.0",
33
33
  "@types/node": "^26.6.6",
34
34
  "@types/progress": "^2.0.7",
package/schema.json CHANGED
@@ -1,7 +1,105 @@
1
1
  {
2
- "$ref": "#/definitions/ITranspilerConfig",
3
2
  "$schema": "http://json-schema.org/draft-07/schema#",
4
3
  "definitions": {
4
+ "ICLITranspilerOptions": {
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "addCommonJS": {
8
+ "description": "adds common js modules",
9
+ "type": "boolean"
10
+ },
11
+ "addFilenames": {
12
+ "description": "adds filenames as comments in the output js",
13
+ "type": "boolean"
14
+ },
15
+ "ignoreSourceMap": {
16
+ "description": "ignore source map",
17
+ "type": "boolean"
18
+ },
19
+ "ignoreSyntaxCheck": {
20
+ "description": "ignore syntax check, used for internal testing",
21
+ "type": "boolean"
22
+ },
23
+ "importProg": {
24
+ "description": "import programs",
25
+ "type": "boolean"
26
+ },
27
+ "keywords": {
28
+ "description": "list of keywords to rename, if not supplied default will be used",
29
+ "items": {
30
+ "type": "string"
31
+ },
32
+ "type": "array"
33
+ },
34
+ "populateTables": {
35
+ "additionalProperties": false,
36
+ "description": "populate tables, all tables are populated if undefined and they exist",
37
+ "properties": {
38
+ "reposrc": {
39
+ "description": "insert into REPOSRC, skips if equals false",
40
+ "type": "boolean"
41
+ },
42
+ "seosubco": {
43
+ "description": "insert into SEOSUBCO, skips if equals false",
44
+ "type": "boolean"
45
+ },
46
+ "seosubcodf": {
47
+ "description": "insert into SEOSUBCODF, skips if equals false",
48
+ "type": "boolean"
49
+ },
50
+ "seosubcotx": {
51
+ "description": "insert into SEOSUBCOTX, skips if equals false",
52
+ "type": "boolean"
53
+ },
54
+ "tadir": {
55
+ "description": "insert into TADIR, skips if equals false",
56
+ "type": "boolean"
57
+ },
58
+ "wwwparams": {
59
+ "description": "insert into WWWPARAMS, skips if equals false",
60
+ "type": "boolean"
61
+ }
62
+ },
63
+ "type": "object"
64
+ },
65
+ "setup": {
66
+ "additionalProperties": false,
67
+ "description": "extra setup script to be executed during initialization",
68
+ "properties": {
69
+ "filename": {
70
+ "type": "string"
71
+ },
72
+ "postFunction": {
73
+ "type": "string"
74
+ },
75
+ "preFunction": {
76
+ "type": "string"
77
+ }
78
+ },
79
+ "required": [
80
+ "filename"
81
+ ],
82
+ "type": "object"
83
+ },
84
+ "sharedTypeFactories": {
85
+ "description": "Deduplicate generated composite type constructors within each output module (default: true).",
86
+ "type": "boolean"
87
+ },
88
+ "skip": {
89
+ "$ref": "#/definitions/TestMethodList",
90
+ "description": "list of unit tests to skip"
91
+ },
92
+ "skipVersionCheck": {
93
+ "description": "skips version check, not recommended",
94
+ "type": "boolean"
95
+ },
96
+ "unknownTypes": {
97
+ "$ref": "#/definitions/UnknownTypesEnum",
98
+ "description": "sets behavior for unknown types, either fail at compile- or run-time"
99
+ }
100
+ },
101
+ "type": "object"
102
+ },
5
103
  "ITranspilerConfig": {
6
104
  "additionalProperties": false,
7
105
  "properties": {
@@ -110,6 +208,10 @@
110
208
  "minLength": 1,
111
209
  "type": "string"
112
210
  },
211
+ "ref": {
212
+ "description": "commit SHA, tag or branch to check out from url; defaults to the default branch",
213
+ "type": "string"
214
+ },
113
215
  "url": {
114
216
  "type": "string"
115
217
  }
@@ -119,7 +221,7 @@
119
221
  "type": "array"
120
222
  },
121
223
  "options": {
122
- "$ref": "#/definitions/ITranspilerOptions"
224
+ "$ref": "#/definitions/ICLITranspilerOptions"
123
225
  },
124
226
  "output_folder": {
125
227
  "minLength": 1,
@@ -143,101 +245,6 @@
143
245
  ],
144
246
  "type": "object"
145
247
  },
146
- "ITranspilerOptions": {
147
- "additionalProperties": false,
148
- "properties": {
149
- "addCommonJS": {
150
- "description": "adds common js modules",
151
- "type": "boolean"
152
- },
153
- "addFilenames": {
154
- "description": "adds filenames as comments in the output js",
155
- "type": "boolean"
156
- },
157
- "ignoreSourceMap": {
158
- "description": "ignore source map",
159
- "type": "boolean"
160
- },
161
- "ignoreSyntaxCheck": {
162
- "description": "ignore syntax check, used for internal testing",
163
- "type": "boolean"
164
- },
165
- "importProg": {
166
- "description": "import programs",
167
- "type": "boolean"
168
- },
169
- "keywords": {
170
- "description": "list of keywords to rename, if not supplied default will be used",
171
- "items": {
172
- "type": "string"
173
- },
174
- "type": "array"
175
- },
176
- "populateTables": {
177
- "additionalProperties": false,
178
- "description": "populate tables, all tables are populated if undefined and they exist",
179
- "properties": {
180
- "reposrc": {
181
- "description": "insert into REPOSRC, skips if equals false",
182
- "type": "boolean"
183
- },
184
- "seosubco": {
185
- "description": "insert into SEOSUBCO, skips if equals false",
186
- "type": "boolean"
187
- },
188
- "seosubcodf": {
189
- "description": "insert into SEOSUBCODF, skips if equals false",
190
- "type": "boolean"
191
- },
192
- "seosubcotx": {
193
- "description": "insert into SEOSUBCOTX, skips if equals false",
194
- "type": "boolean"
195
- },
196
- "tadir": {
197
- "description": "insert into TADIR, skips if equals false",
198
- "type": "boolean"
199
- },
200
- "wwwparams": {
201
- "description": "insert into WWWPARAMS, skips if equals false",
202
- "type": "boolean"
203
- }
204
- },
205
- "type": "object"
206
- },
207
- "setup": {
208
- "additionalProperties": false,
209
- "description": "extra setup script to be executed during initialization",
210
- "properties": {
211
- "filename": {
212
- "type": "string"
213
- },
214
- "postFunction": {
215
- "type": "string"
216
- },
217
- "preFunction": {
218
- "type": "string"
219
- }
220
- },
221
- "required": [
222
- "filename"
223
- ],
224
- "type": "object"
225
- },
226
- "skip": {
227
- "$ref": "#/definitions/TestMethodList",
228
- "description": "list of unit tests to skip"
229
- },
230
- "skipVersionCheck": {
231
- "description": "skips version check, not recommended",
232
- "type": "boolean"
233
- },
234
- "unknownTypes": {
235
- "$ref": "#/definitions/UnknownTypesEnum",
236
- "description": "sets behavior for unknown types, either fail at compile- or run-time"
237
- }
238
- },
239
- "type": "object"
240
- },
241
248
  "TestMethodList": {
242
249
  "items": {
243
250
  "additionalProperties": false,