@abaplint/transpiler-cli 2.7.5 → 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.
Files changed (2) hide show
  1. package/build/bundle.js +274 -36
  2. 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
- if (from) {
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
- for (const s of node.findAllExpressions(Expressions.Source)) {
24377
- new source_1.Source().runSyntax(s, scope, filename);
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 s of node.findAllExpressions(Expressions.SimpleSource3)) {
24380
- new source_1.Source().runSyntax(s, scope, filename);
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.100.4";
46936
+ return "2.101.0";
46815
46937
  }
46816
46938
  getDDICReferences() {
46817
46939
  return this.ddicReferences;
@@ -56152,7 +56274,16 @@ IF condition1.
56152
56274
  ...
56153
56275
  ELSEIF condition2.
56154
56276
  ...
56155
- ENDIF.`,
56277
+ ENDIF.
56278
+
56279
+ CASE variable.
56280
+ WHEN value1.
56281
+ ...
56282
+ WHEN value2.
56283
+ IF condition2.
56284
+ ...
56285
+ ENDIF.
56286
+ ENDCASE.`,
56156
56287
  tags: [_irule_1.RuleTag.Styleguide, _irule_1.RuleTag.SingleFile, _irule_1.RuleTag.Quickfix],
56157
56288
  };
56158
56289
  }
@@ -56897,6 +57028,7 @@ __exportStar(__webpack_require__(/*! ./smim_consistency */ "./node_modules/@abap
56897
57028
  __exportStar(__webpack_require__(/*! ./space_before_colon */ "./node_modules/@abaplint/core/build/src/rules/space_before_colon.js"), exports);
56898
57029
  __exportStar(__webpack_require__(/*! ./space_before_dot */ "./node_modules/@abaplint/core/build/src/rules/space_before_dot.js"), exports);
56899
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);
56900
57032
  __exportStar(__webpack_require__(/*! ./start_at_tab */ "./node_modules/@abaplint/core/build/src/rules/start_at_tab.js"), exports);
56901
57033
  __exportStar(__webpack_require__(/*! ./static_call_via_instance */ "./node_modules/@abaplint/core/build/src/rules/static_call_via_instance.js"), exports);
56902
57034
  __exportStar(__webpack_require__(/*! ./strict_sql */ "./node_modules/@abaplint/core/build/src/rules/strict_sql.js"), exports);
@@ -62481,6 +62613,9 @@ class ReduceStringTemplates extends _abap_rule_1.ABAPRule {
62481
62613
  for (const second of source.findDirectExpressions(Expressions.StringTemplate)) {
62482
62614
  issues.push(issue_1.Issue.atToken(file, second.getFirstToken(), "Nested string templates, reduce", this.getMetadata().key, this.conf.severity));
62483
62615
  }
62616
+ if (ts.findDirectExpression(Expressions.StringTemplateFormatting)) {
62617
+ continue;
62618
+ }
62484
62619
  for (const constant of source.findDirectExpressions(Expressions.Constant)) {
62485
62620
  for (const constantString of constant.findDirectExpressions(Expressions.ConstantString)) {
62486
62621
  issues.push(issue_1.Issue.atToken(file, constantString.getFirstToken(), "Constant string in text template, reduce", this.getMetadata().key, this.conf.severity));
@@ -64022,6 +64157,81 @@ exports.SQLEscapeHostVariables = SQLEscapeHostVariables;
64022
64157
 
64023
64158
  /***/ }),
64024
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
+
64025
64235
  /***/ "./node_modules/@abaplint/core/build/src/rules/start_at_tab.js":
64026
64236
  /*!*********************************************************************!*\
64027
64237
  !*** ./node_modules/@abaplint/core/build/src/rules/start_at_tab.js ***!
@@ -64771,13 +64981,15 @@ class TypesNaming extends _abap_rule_1.ABAPRule {
64771
64981
  if (stat.get() instanceof Statements.Type && nesting === 0) {
64772
64982
  expr = stat.findFirstExpression(Expressions.NamespaceSimpleName);
64773
64983
  }
64774
- else if (stat.get() instanceof Statements.TypeBegin) {
64984
+ else if (stat.get() instanceof Statements.TypeBegin
64985
+ || stat.get() instanceof Statements.TypeEnumBegin) {
64775
64986
  if (nesting === 0) {
64776
64987
  expr = stat.findFirstExpression(Expressions.NamespaceSimpleName);
64777
64988
  }
64778
64989
  nesting = nesting + 1;
64779
64990
  }
64780
- else if (stat.get() instanceof Statements.TypeEnd) {
64991
+ else if (stat.get() instanceof Statements.TypeEnd
64992
+ || stat.get() instanceof Statements.TypeEnumEnd) {
64781
64993
  nesting = nesting - 1;
64782
64994
  continue;
64783
64995
  }
@@ -70393,8 +70605,9 @@ const chunk_1 = __webpack_require__(/*! ../chunk */ "./node_modules/@abaplint/tr
70393
70605
  const simple_source3_1 = __webpack_require__(/*! ./simple_source3 */ "./node_modules/@abaplint/transpiler/build/src/expressions/simple_source3.js");
70394
70606
  const field_chain_1 = __webpack_require__(/*! ./field_chain */ "./node_modules/@abaplint/transpiler/build/src/expressions/field_chain.js");
70395
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");
70396
70609
  class SQLCondTranspiler {
70397
- transpile(node, traversal) {
70610
+ transpile(node, traversal, table) {
70398
70611
  var _a;
70399
70612
  let ret = "";
70400
70613
  for (const c of node.getChildren()) {
@@ -70417,11 +70630,11 @@ class SQLCondTranspiler {
70417
70630
  ret += this.sqlIn(c, traversal);
70418
70631
  }
70419
70632
  else {
70420
- ret += this.basicCondition(c, traversal, traversal.getFilename());
70633
+ ret += this.basicCondition(c, traversal, traversal.getFilename(), table);
70421
70634
  }
70422
70635
  }
70423
70636
  else if (c instanceof abaplint.Nodes.ExpressionNode) {
70424
- ret += " " + this.transpile(c, traversal).getCode();
70637
+ ret += " " + this.transpile(c, traversal, table).getCode();
70425
70638
  }
70426
70639
  else {
70427
70640
  ret += " " + c.concatTokens();
@@ -70440,10 +70653,10 @@ class SQLCondTranspiler {
70440
70653
  const ret = `" + abap.expandIN("${fieldName.concatTokens()}", ${source.concatTokens()}) + "`;
70441
70654
  return ret;
70442
70655
  }
70443
- basicCondition(c, traversal, filename) {
70656
+ basicCondition(c, traversal, filename, table) {
70444
70657
  let ret = "";
70445
70658
  if (c.getChildren().length !== 3) {
70446
- return this.basicConditionNew(c, traversal, filename);
70659
+ return this.basicConditionNew(c, traversal, filename, table);
70447
70660
  }
70448
70661
  let fieldName = undefined;
70449
70662
  const fieldNameExpression = c.findDirectExpression(abaplint.Expressions.SQLFieldName);
@@ -70454,7 +70667,7 @@ class SQLCondTranspiler {
70454
70667
  const source = c.findDirectExpression(abaplint.Expressions.SQLSource);
70455
70668
  if (fieldName && source && operator === undefined && c.findDirectTokenByText("LIKE")) {
70456
70669
  ret += fieldName + " LIKE ";
70457
- ret += this.sqlSource(source, traversal, filename);
70670
+ ret += this.sqlSource(source, traversal, filename, table);
70458
70671
  return ret;
70459
70672
  }
70460
70673
  if (fieldName === undefined || operator === undefined || source === undefined) {
@@ -70468,10 +70681,10 @@ class SQLCondTranspiler {
70468
70681
  op = "<>";
70469
70682
  }
70470
70683
  ret += fieldName + " " + op + " ";
70471
- ret += this.sqlSource(source, traversal, filename);
70684
+ ret += this.sqlSource(source, traversal, filename, table);
70472
70685
  return ret;
70473
70686
  }
70474
- sqlSource(source, traversal, filename) {
70687
+ sqlSource(source, traversal, filename, table) {
70475
70688
  let ret = "";
70476
70689
  const simple = source.findDirectExpression(abaplint.Expressions.SimpleSource3);
70477
70690
  const alias = source.findDirectExpression(abaplint.Expressions.SQLAliasField);
@@ -70497,7 +70710,12 @@ class SQLCondTranspiler {
70497
70710
  }
70498
70711
  else {
70499
70712
  const concat = source.concatTokens();
70500
- if (concat.startsWith("`")) {
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("`")) {
70501
70719
  ret += "'" + concat.substring(1, concat.length - 1) + "'";
70502
70720
  }
70503
70721
  else {
@@ -70506,7 +70724,7 @@ class SQLCondTranspiler {
70506
70724
  }
70507
70725
  return ret;
70508
70726
  }
70509
- basicConditionNew(node, traversal, filename) {
70727
+ basicConditionNew(node, traversal, filename, table) {
70510
70728
  let ret = "";
70511
70729
  for (const child of node.getChildren()) {
70512
70730
  if (ret !== "") {
@@ -70518,7 +70736,7 @@ class SQLCondTranspiler {
70518
70736
  }
70519
70737
  else if (child.get() instanceof abaplint.Expressions.SQLSource
70520
70738
  && child instanceof abaplint.Nodes.ExpressionNode) {
70521
- ret += this.sqlSource(child, traversal, filename);
70739
+ ret += this.sqlSource(child, traversal, filename, table);
70522
70740
  }
70523
70741
  else {
70524
70742
  ret += child.concatTokens();
@@ -70626,13 +70844,19 @@ class SQLFromTranspiler {
70626
70844
  }
70627
70845
  else {
70628
70846
  if (c.findFirstExpression(abaplint.Expressions.Dynamic)) {
70629
- chunk.appendString(c.concatTokens() + " ");
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 + " ");
70630
70853
  }
70631
70854
  else if (c.concatTokens().includes("/")) {
70632
- chunk.appendString("'" + c.concatTokens() + "' ");
70855
+ chunk.appendString("\\\"" + c.concatTokens() + "\\\" ");
70633
70856
  }
70634
70857
  else {
70635
- chunk.appendString(c.concatTokens() + " ");
70858
+ const concat = c.concatTokens();
70859
+ chunk.appendString(concat + " ");
70636
70860
  }
70637
70861
  }
70638
70862
  }
@@ -70665,7 +70889,11 @@ class SQLFromSourceTranspiler {
70665
70889
  chunk.appendString(c.concatTokens() + " ");
70666
70890
  }
70667
70891
  else if (c.get() instanceof abaplint.Expressions.DatabaseTable && c.concatTokens().includes("/")) {
70668
- chunk.appendString("'" + c.concatTokens() + "' ");
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() + "\\\" ");
70669
70897
  }
70670
70898
  else {
70671
70899
  chunk.appendString(c.concatTokens() + " ");
@@ -74753,7 +74981,7 @@ class InsertDatabaseTranspiler {
74753
74981
  const tvalues = traversal.traverse(fromTable);
74754
74982
  options.push(`"table": ` + tvalues.getCode());
74755
74983
  }
74756
- 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(", ")}});`);
74757
74985
  }
74758
74986
  }
74759
74987
  exports.InsertDatabaseTranspiler = InsertDatabaseTranspiler;
@@ -76229,6 +76457,7 @@ class SelectTranspiler {
76229
76457
  if (from) {
76230
76458
  select += new sql_from_1.SQLFromTranspiler().transpile(from, traversal).getCode();
76231
76459
  }
76460
+ const { table, keys } = this.findTable(node, traversal);
76232
76461
  let where = undefined;
76233
76462
  for (const sqlCond of node.findAllExpressions(abaplint.Expressions.SQLCond)) {
76234
76463
  if (this.isWhereExpression(node, sqlCond)) {
@@ -76236,7 +76465,7 @@ class SelectTranspiler {
76236
76465
  }
76237
76466
  }
76238
76467
  if (where) {
76239
- select += "WHERE " + traversal.traverse(where).getCode() + " ";
76468
+ select += "WHERE " + new expressions_1.SQLCondTranspiler().transpile(where, traversal, table).getCode() + " ";
76240
76469
  }
76241
76470
  const upTo = node.findFirstExpression(abaplint.Expressions.SQLUpTo);
76242
76471
  if (upTo) {
@@ -76272,7 +76501,6 @@ class SelectTranspiler {
76272
76501
  runtimeOptions = `, {` + runtimeOptionsList.join(", ") + `}`;
76273
76502
  }
76274
76503
  let extra = "";
76275
- const keys = this.findKeys(node, traversal);
76276
76504
  if (keys.length > 0) {
76277
76505
  extra = `, primaryKey: ${JSON.stringify(keys)}`;
76278
76506
  }
@@ -76305,16 +76533,17 @@ class SelectTranspiler {
76305
76533
  return new chunk_1.Chunk().append(`await abap.statements.select(${target}, {select: "${select.trim()}"${extra}}${runtimeOptions});`, node, traversal);
76306
76534
  }
76307
76535
  }
76308
- findKeys(node, traversal) {
76536
+ findTable(node, traversal) {
76309
76537
  let keys = [];
76538
+ let tabl = undefined;
76310
76539
  const from = node.findAllExpressions(abaplint.Expressions.SQLFromSource).map(e => e.concatTokens());
76311
76540
  if (from.length === 1) {
76312
- const tabl = traversal.findTable(from[0]);
76541
+ tabl = traversal.findTable(from[0]);
76313
76542
  if (tabl) {
76314
76543
  keys = tabl.listKeys(traversal.reg).map(k => k.toLowerCase());
76315
76544
  }
76316
76545
  }
76317
- return keys;
76546
+ return { table: tabl, keys };
76318
76547
  }
76319
76548
  isWhereExpression(node, expression) {
76320
76549
  // check if previous token before sqlCond is "WHERE". It could also be "ON" in case of join condition
@@ -77098,7 +77327,7 @@ class UpdateDatabaseTranspiler {
77098
77327
  for (const set of sets) {
77099
77328
  const name = (_a = set.findDirectExpression(abaplint.Expressions.SQLFieldName)) === null || _a === void 0 ? void 0 : _a.concatTokens();
77100
77329
  const source = traversal.traverse(set.findDirectExpression(abaplint.Expressions.SQLSource));
77101
- s.push("\"'" + name + "' = '\" + " + source.getCode() + ".get() + \"'\"");
77330
+ s.push("\"\\\"" + name + "\\\" = '\" + " + source.getCode() + ".get() + \"'\"");
77102
77331
  }
77103
77332
  options.push(`"set": [${s.join(",")}]`);
77104
77333
  }
@@ -78799,6 +79028,15 @@ class Traversal {
78799
79028
  }
78800
79029
  return false;
78801
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
+ }
78802
79040
  findMethodReference(token, scope) {
78803
79041
  var _a, _b;
78804
79042
  let candidate = undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abaplint/transpiler-cli",
3
- "version": "2.7.5",
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.5",
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.100.4",
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",