@sap/cds-compiler 2.5.2 → 2.11.0

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 (102) hide show
  1. package/CHANGELOG.md +235 -9
  2. package/bin/cdsc.js +44 -27
  3. package/bin/cdsse.js +1 -0
  4. package/doc/CHANGELOG_BETA.md +37 -3
  5. package/lib/api/.eslintrc.json +2 -0
  6. package/lib/api/main.js +37 -123
  7. package/lib/api/options.js +27 -15
  8. package/lib/api/validate.js +34 -9
  9. package/lib/backends.js +9 -89
  10. package/lib/base/dictionaries.js +2 -1
  11. package/lib/base/keywords.js +32 -2
  12. package/lib/base/message-registry.js +73 -11
  13. package/lib/base/messages.js +86 -30
  14. package/lib/base/model.js +6 -6
  15. package/lib/base/optionProcessorHelper.js +56 -22
  16. package/lib/checks/defaultValues.js +27 -2
  17. package/lib/checks/elements.js +1 -6
  18. package/lib/checks/foreignKeys.js +0 -6
  19. package/lib/checks/managedWithoutKeys.js +17 -0
  20. package/lib/checks/nonexpandableStructured.js +38 -0
  21. package/lib/checks/onConditions.js +9 -45
  22. package/lib/checks/queryNoDbArtifacts.js +25 -7
  23. package/lib/checks/selectItems.js +29 -2
  24. package/lib/checks/types.js +26 -2
  25. package/lib/checks/unknownMagic.js +41 -0
  26. package/lib/checks/utils.js +61 -0
  27. package/lib/checks/validator.js +60 -7
  28. package/lib/compiler/assert-consistency.js +23 -7
  29. package/lib/compiler/base.js +65 -0
  30. package/lib/compiler/builtins.js +30 -1
  31. package/lib/compiler/checks.js +8 -5
  32. package/lib/compiler/definer.js +157 -133
  33. package/lib/compiler/index.js +89 -31
  34. package/lib/compiler/propagator.js +5 -2
  35. package/lib/compiler/resolver.js +375 -185
  36. package/lib/compiler/shared.js +49 -202
  37. package/lib/compiler/utils.js +173 -0
  38. package/lib/edm/annotations/genericTranslation.js +183 -187
  39. package/lib/edm/csn2edm.js +104 -108
  40. package/lib/edm/edm.js +18 -21
  41. package/lib/edm/edmPreprocessor.js +388 -146
  42. package/lib/edm/edmUtils.js +104 -34
  43. package/lib/gen/Dictionary.json +22 -0
  44. package/lib/gen/language.checksum +1 -1
  45. package/lib/gen/language.interp +28 -1
  46. package/lib/gen/language.tokens +79 -69
  47. package/lib/gen/languageLexer.interp +28 -1
  48. package/lib/gen/languageLexer.js +879 -805
  49. package/lib/gen/languageLexer.tokens +71 -62
  50. package/lib/gen/languageParser.js +5330 -4300
  51. package/lib/json/from-csn.js +110 -52
  52. package/lib/json/to-csn.js +434 -120
  53. package/lib/language/antlrParser.js +15 -3
  54. package/lib/language/errorStrategy.js +1 -0
  55. package/lib/language/genericAntlrParser.js +93 -26
  56. package/lib/language/language.g4 +172 -31
  57. package/lib/main.d.ts +216 -19
  58. package/lib/main.js +32 -7
  59. package/lib/model/api.js +78 -0
  60. package/lib/model/csnRefs.js +413 -149
  61. package/lib/model/csnUtils.js +286 -75
  62. package/lib/model/enrichCsn.js +50 -6
  63. package/lib/model/revealInternalProperties.js +22 -5
  64. package/lib/modelCompare/compare.js +39 -21
  65. package/lib/optionProcessor.js +35 -18
  66. package/lib/render/.eslintrc.json +4 -1
  67. package/lib/render/DuplicateChecker.js +9 -6
  68. package/lib/render/toCdl.js +121 -36
  69. package/lib/render/toHdbcds.js +148 -98
  70. package/lib/render/toSql.js +114 -43
  71. package/lib/render/utils/common.js +8 -13
  72. package/lib/render/utils/sql.js +3 -3
  73. package/lib/sql-identifier.js +6 -1
  74. package/lib/transform/db/assertUnique.js +5 -6
  75. package/lib/transform/db/constraints.js +281 -106
  76. package/lib/transform/db/draft.js +11 -8
  77. package/lib/transform/db/expansion.js +584 -0
  78. package/lib/transform/db/flattening.js +341 -0
  79. package/lib/transform/db/groupByOrderBy.js +2 -2
  80. package/lib/transform/db/transformExists.js +345 -65
  81. package/lib/transform/db/views.js +438 -0
  82. package/lib/transform/forHanaNew.js +131 -793
  83. package/lib/transform/forOdataNew.js +30 -24
  84. package/lib/transform/localized.js +39 -10
  85. package/lib/transform/odata/attachPath.js +19 -4
  86. package/lib/transform/odata/generateForeignKeyElements.js +11 -10
  87. package/lib/transform/odata/referenceFlattener.js +60 -39
  88. package/lib/transform/odata/sortByAssociationDependency.js +2 -2
  89. package/lib/transform/odata/structuralPath.js +72 -0
  90. package/lib/transform/odata/structureFlattener.js +19 -18
  91. package/lib/transform/odata/typesExposure.js +22 -12
  92. package/lib/transform/transformUtilsNew.js +144 -78
  93. package/lib/transform/translateAssocsToJoins.js +22 -27
  94. package/lib/transform/universalCsnEnricher.js +67 -0
  95. package/lib/utils/file.js +5 -14
  96. package/lib/utils/moduleResolve.js +6 -8
  97. package/lib/utils/term.js +65 -42
  98. package/lib/utils/timetrace.js +48 -26
  99. package/package.json +1 -1
  100. package/lib/json/walker.js +0 -26
  101. package/lib/transform/sqlite +0 -0
  102. package/lib/utils/string.js +0 -17
@@ -13,6 +13,8 @@
13
13
 
14
14
  const msg = require('../base/messages');
15
15
 
16
+ const $inferred = Symbol.for('cds.$inferred');
17
+
16
18
  class NOT_A_DICTIONARY {} // used for consol.log display
17
19
 
18
20
  function locationString( loc ) {
@@ -32,15 +34,22 @@ const kindsRepresentedAsLinks = {
32
34
  // represent SELECTs in query / SET-args property as link:
33
35
  select: (art, parent) => art._main && parent !== art._main.$queries,
34
36
  // represent table alias in from / join-args property as link:
35
- $tableAlias: (art, parent) => art._parent && parent !== art._parent.$tableAliases,
36
- // represent table alias in JOIN node as link:
37
+ $tableAlias: tableAliasAsLink,
38
+ // represent "navigation elemens" in _combined as links:
37
39
  $navElement: (art, parent) => art._parent && parent !== art._parent.elements,
38
40
  // represent mixin in $tableAliases as link:
39
- mixin: (art, parent) => art._parent && parent !== art._parent.mixin,
41
+ mixin: tableAliasAsLink,
40
42
  // represent $projection as link, as it is just another search name for $self:
41
43
  $self: (_a, _p, name) => name !== '$self',
42
44
  }
43
45
 
46
+ function tableAliasAsLink( art, parent, name ) {
47
+ return art._parent && art._parent.$tableAliases && // initXYZ() is run
48
+ parent !== art._parent.$tableAliases && // not in $tableAliases
49
+ !(art.$duplicates === true && name && // and its $duplicates
50
+ parent === art._parent.$tableAliases[name].$duplicates);
51
+ }
52
+
44
53
  function revealInternalProperties( model, name ) {
45
54
  const transformers = {
46
55
  messages: m => m,
@@ -65,6 +74,7 @@ function revealInternalProperties( model, name ) {
65
74
  mixin: dictionary,
66
75
  args: dictionary,
67
76
  $tableAliases: dictionary,
77
+ $duplicates: duplicates,
68
78
  $keysNavigation: dictionary,
69
79
  $layerNumber: n => n,
70
80
  $extra: e => e,
@@ -76,6 +86,7 @@ function revealInternalProperties( model, name ) {
76
86
  _annotate: reveal,
77
87
  _deps: dependencyInfo,
78
88
  _status: primOrString, // is a string anyway
89
+ $messageFunctions: () => '‹some functions›',
79
90
  }
80
91
  unique_id = 1;
81
92
  return revealXsnPath(name, model);
@@ -159,7 +170,7 @@ function revealInternalProperties( model, name ) {
159
170
 
160
171
  function columns( nodes, query ) {
161
172
  // If we will have specified elements, we need another test to see columns in --parse-cdl
162
- return nodes && nodes.map( c => (c._parent && c._parent.elements && c.kind !== '$inline')
173
+ return nodes && nodes.map( c => (c._parent && c._parent.elements)
163
174
  ? artifactIdentifier( c, query )
164
175
  : reveal( c, nodes ) );
165
176
  }
@@ -202,6 +213,8 @@ function revealInternalProperties( model, name ) {
202
213
  for (let prop of Object.getOwnPropertyNames( node )) { // also non-enumerable
203
214
  r[prop] = reveal( node[prop], node, prop );
204
215
  }
216
+ if (node[$inferred] && !node['[$inferred]'])
217
+ r['[$inferred]'] = node[$inferred];
205
218
  return r;
206
219
  }
207
220
 
@@ -227,7 +240,7 @@ function revealInternalProperties( model, name ) {
227
240
  if (node == null || typeof node !== 'object' )
228
241
  return node
229
242
  if (Array.isArray(node))
230
- return node.map( n => reveal( n, node ) );
243
+ return node.map( n => reveal( n, node, name ) );
231
244
 
232
245
  const asLinkTest = kindsRepresentedAsLinks[ node.kind ];
233
246
  if (asLinkTest && asLinkTest( node, parent, name ))
@@ -245,6 +258,10 @@ function revealInternalProperties( model, name ) {
245
258
  }
246
259
  return r;
247
260
  }
261
+
262
+ function duplicates( node, parent ) {
263
+ return reveal( node, parent, parent.name && parent.name.id );
264
+ }
248
265
  }
249
266
 
250
267
  function artifactIdentifier( node, parent ) {
@@ -12,27 +12,28 @@ const {
12
12
  *
13
13
  * @param beforeModel the before-model
14
14
  * @param afterModel the after-model
15
- * @param {hdiOptions|false} options
15
+ * @param {import('../api/main.js').hdiOptions|false} options
16
16
  * @returns {object} the sets of deletions, extensions, and migrations of entities necessary to transform the before-model
17
17
  * to the after-model, together with all the definitions of the after-model
18
18
  */
19
19
  function compareModels(beforeModel, afterModel, options) {
20
+ // @ts-ignore
20
21
  if(!(options && options.testMode)) // no $version with testMode
21
22
  validateCsnVersions(beforeModel, afterModel, options);
22
23
 
23
24
  const deletedEntities = Object.create(null);
24
25
  const elementAdditions = [];
25
- const elementChanges = [];
26
+ const migrations = []; // element changes/removals or changes of entity properties
26
27
 
27
28
  // There is currently no use in knowing the added entities only. If this changes, hand in `addedEntities` to `getArtifactComparator` below.
28
- forEachDefinition(afterModel, getArtifactComparator(beforeModel, null, null, elementAdditions, elementChanges)); // (, alerts(afterModel))
29
- forEachDefinition(beforeModel, getArtifactComparator(afterModel, null, deletedEntities, null, null)); // (, alerts(beforeModel))
29
+ forEachDefinition(afterModel, getArtifactComparator(beforeModel, null, null, elementAdditions, migrations));
30
+ forEachDefinition(beforeModel, getArtifactComparator(afterModel, null, deletedEntities, null, null));
30
31
 
31
32
  const returnObj = Object.create(null);
32
33
  returnObj.definitions = afterModel.definitions;
33
34
  returnObj.deletions = deletedEntities;
34
35
  returnObj.extensions = elementAdditions;
35
- returnObj.migrations = elementChanges;
36
+ returnObj.migrations = migrations;
36
37
  return returnObj;
37
38
  }
38
39
 
@@ -59,35 +60,45 @@ function validateCsnVersions(beforeModel, afterModel, options) {
59
60
  }
60
61
  }
61
62
 
62
- function getArtifactComparator(otherModel, addedEntities, deletedEntities, elementAdditions, elementChanges) { // (, alerts)
63
- return function compareArtifacts(artifact, name) { // (, topKey, path) topKey == 'definitions'
63
+ function getArtifactComparator(otherModel, addedEntities, deletedEntities, elementAdditions, migrations) {
64
+ return function compareArtifacts(artifact, name) {
64
65
  function addElements() {
65
66
  const elements = {};
66
67
  forEachMember(artifact, getElementComparator(otherArtifact, elements));
67
68
  if (Object.keys(elements).length > 0) {
68
- elementAdditions.push({
69
- extend: name,
70
- elements: elements
71
- });
69
+ elementAdditions.push(addedElements(name, elements));
72
70
  }
73
71
  }
74
- function removeOrChangeElements() {
72
+ function changePropsOrRemoveOrChangeElements() {
73
+ const relevantProperties = ['doc'];
74
+ const changedProperties = {};
75
+
75
76
  const removedElements = {};
76
77
  const changedElements = {};
77
- const modification = { migrate: name };
78
+
79
+ const migration = { migrate: name };
80
+
81
+ relevantProperties.forEach(prop => {
82
+ if (artifact[prop] !== otherArtifact[prop]) {
83
+ changedProperties[prop] = changedElement(artifact[prop], otherArtifact[prop] || null);
84
+ }
85
+ });
86
+ if (Object.keys(changedProperties).length > 0) {
87
+ migration.properties = changedProperties;
88
+ }
78
89
 
79
90
  forEachMember(otherArtifact, getElementComparator(artifact, removedElements));
80
91
  if (Object.keys(removedElements).length > 0) {
81
- modification.remove = removedElements;
92
+ migration.remove = removedElements;
82
93
  }
83
94
 
84
95
  forEachMember(artifact, getElementComparator(otherArtifact, null, changedElements));
85
96
  if (Object.keys(changedElements).length > 0) {
86
- modification.change = changedElements;
97
+ migration.change = changedElements;
87
98
  }
88
99
 
89
- if (modification.remove || modification.change) {
90
- elementChanges.push(modification);
100
+ if (migration.properties || migration.remove || migration.change) {
101
+ migrations.push(migration);
91
102
  }
92
103
  }
93
104
 
@@ -124,8 +135,8 @@ function getArtifactComparator(otherModel, addedEntities, deletedEntities, eleme
124
135
  if (elementAdditions) {
125
136
  addElements();
126
137
  }
127
- if (elementChanges) {
128
- removeOrChangeElements();
138
+ if (migrations) {
139
+ changePropsOrRemoveOrChangeElements();
129
140
  }
130
141
  };
131
142
  }
@@ -139,8 +150,8 @@ function isPersistedAsTable(artifact) {
139
150
  && !hasAnnotationValue(artifact, '@cds.persistence.exists');
140
151
  }
141
152
 
142
- function getElementComparator(otherArtifact, addedElements = null, changedElements = null) { // (, alerts)
143
- return function compareElements(element, name) { // (, topKey, path) topKey == 'elements'
153
+ function getElementComparator(otherArtifact, addedElements = null, changedElements = null) {
154
+ return function compareElements(element, name) {
144
155
  if (element._ignore) {
145
156
  return;
146
157
  }
@@ -209,6 +220,13 @@ function typeParametersChanged(element, otherElement) {
209
220
  return !deepEqual(element, otherElement, (key, depth) => !(depth === 0 && key === 'type'));
210
221
  }
211
222
 
223
+ function addedElements(entity, elements) {
224
+ return {
225
+ extend: entity,
226
+ elements
227
+ };
228
+ }
229
+
212
230
  function changedElement(element, otherElement) {
213
231
  return {
214
232
  old: otherElement,
@@ -27,8 +27,10 @@ optionProcessor
27
27
  .option(' --internal-msg')
28
28
  .option(' --beta-mode')
29
29
  .option(' --beta <list>')
30
- .option(' --constraints-not-validated')
31
- .option(' --constraints-not-enforced')
30
+ .option(' --integrity-not-validated')
31
+ .option(' --integrity-not-enforced')
32
+ .option(' --assert-integrity <mode>', [ 'true', 'false', 'individual' ])
33
+ .option(' --assert-integrity-type <type>', [ 'RT', 'DB' ])
32
34
  .option(' --deprecated <list>')
33
35
  .option(' --hana-flavor')
34
36
  .option(' --direct-backend')
@@ -37,8 +39,11 @@ optionProcessor
37
39
  .option(' --test-mode')
38
40
  .option(' --test-sort-csn')
39
41
  .option(' --doc-comment')
42
+ .option(' --add-texts-language-assoc')
40
43
  .option(' --localized-without-coalesce')
41
- .option(' --defaultStringLength <length>')
44
+ .option(' --default-binary-length <length>')
45
+ .option(' --default-string-length <length>')
46
+ .option(' --no-recompile')
42
47
  .positionalArgument('<files...>')
43
48
  .help(`
44
49
  Usage: cdsc <command> [options] <files...>
@@ -73,7 +78,8 @@ optionProcessor
73
78
  -- Indicate the end of options (helpful if source names start with "-")
74
79
 
75
80
  Type options
76
- --defaultStringLength <length> Default 'length' for 'cds.String'
81
+ --default-binary-length <length> Default 'length' for 'cds.Binary'
82
+ --default-string-length <length> Default 'length' for 'cds.String'
77
83
 
78
84
  Diagnostic options
79
85
  --trace-parser Trace parser
@@ -88,16 +94,23 @@ optionProcessor
88
94
  --beta-mode Enable all unsupported, incomplete (beta) features
89
95
  --beta <list> Comma separated list of unsupported, incomplete (beta) features to use.
90
96
  Valid values are:
91
- keylessManagedAssoc
92
- foreignKeyConstraints
93
97
  addTextsLanguageAssoc
94
98
  hanaAssocRealCardinality
95
99
  mapAssocToJoinCardinality
96
100
  ignoreAssocPublishingInUnion
97
- --constraints-not-enforced If this option is supplied, referential constraints are NOT ENFORCED
98
- This option is also applied to result of "cdsc manageConstraints"
99
- --constraints-not-validated If this option is supplied, referential constraints are NOT VALIDATED
100
- This option is also applied to result of "cdsc manageConstraints"
101
+ --integrity-not-enforced If this option is supplied, referential constraints are NOT ENFORCED.
102
+ This option is also applied to result of "cdsc manageConstraints"
103
+ --integrity-not-validated If this option is supplied, referential constraints are NOT VALIDATED.
104
+ This option is also applied to result of "cdsc manageConstraints"
105
+ --assert-integrity <mode> Turn DB constraints on/off:
106
+ true : Constraints will be generated for all associations if
107
+ the assert-integrity-type is set to DB
108
+ false : No constraints will be generated
109
+ individual : Constraints will be generated for selected associations
110
+ --assert-integrity-type <type> Specifies how the referential integrity checks should be performed:
111
+ RT : (default) No database constraint for an association
112
+ if not explicitly demanded via annotation
113
+ DB : Create database constraints for associations
101
114
  --deprecated <list> Comma separated list of deprecated options.
102
115
  Valid values are:
103
116
  noElementsExpansion
@@ -124,7 +137,10 @@ optionProcessor
124
137
  OData CSN, CDL order and more. When --test-mode is enabled, this
125
138
  option is implicitly enabled as well.
126
139
  --doc-comment Preserve /** */ comments at annotation positions as doc property in CSN
140
+ --add-texts-language-assoc In generated texts entities, add association "language"
141
+ to "sap.common.Languages" if it exists
127
142
  --localized-without-coalesce Omit coalesce in localized convenience views
143
+ --no-recompile Don't recompile in case of internal errors
128
144
 
129
145
  Commands
130
146
  H, toHana [options] <files...> Generate HANA CDS source files
@@ -135,7 +151,7 @@ optionProcessor
135
151
  parseCdl [options] <file> Generate a CSN that is close to the CDL source.
136
152
  explain <message-id> Explain a compiler message.
137
153
  toRename [options] <files...> (internal) Generate SQL DDL rename statements
138
- manageConstraints [options] <files...> (internal) Generate ALTER TABLE statements to
154
+ manageConstraints [options] <files...> (internal) Generate ALTER TABLE statements to
139
155
  add / modify referential constraints.
140
156
  `);
141
157
 
@@ -145,7 +161,6 @@ optionProcessor.command('H, toHana')
145
161
  .option('-n, --names <style>', ['plain', 'quoted', 'hdbcds'])
146
162
  .option(' --render-virtual')
147
163
  .option(' --joinfk')
148
- .option(' --skip-db-constraints')
149
164
  .option('-u, --user <user>')
150
165
  .option('-s, --src')
151
166
  .option('-c, --csn')
@@ -169,7 +184,6 @@ optionProcessor.command('H, toHana')
169
184
  using element names with dots).
170
185
  --render-virtual Render virtual elements in views and draft tables
171
186
  --joinfk Create JOINs for foreign key accesses
172
- --skip-db-constraints Do not render referential constraints for associations
173
187
  -u, --user <user> Value for the "$user" variable
174
188
  -s, --src (default) Generate HANA CDS source files "<artifact>.hdbcds"
175
189
  -c, --csn Generate "hana_csn.json" with HANA-preprocessed model
@@ -236,7 +250,6 @@ optionProcessor.command('Q, toSql')
236
250
  .option('-n, --names <style>', ['plain', 'quoted', 'hdbcds'])
237
251
  .option(' --render-virtual')
238
252
  .option(' --joinfk')
239
- .option(' --skip-db-constraints')
240
253
  .option('-d, --dialect <dialect>', ['hana', 'sqlite', 'plain'])
241
254
  .option('-u, --user <user>')
242
255
  .option('-l, --locale <locale>')
@@ -262,7 +275,6 @@ optionProcessor.command('Q, toSql')
262
275
  combination with "hana" dialect.
263
276
  --render-virtual Render virtual elements in views and draft tables
264
277
  --joinfk Create JOINs for foreign key accesses
265
- --skip-db-constraints Do not render referential constraints for associations
266
278
  -d, --dialect <dialect> SQL dialect to be generated:
267
279
  plain : (default) Common SQL - no assumptions about DB restrictions
268
280
  hana : SQL with HANA specific language features
@@ -310,7 +322,7 @@ optionProcessor.command('manageConstraints')
310
322
 
311
323
  (internal, subject to change): Generate SQL DDL ALTER TABLE statements to add / modify
312
324
  referential constraints on an existing model.
313
- Combine with options "--constraints-not-enforced" and "--constraint-not-validated"
325
+ Combine with options "--integrity-not-enforced" and "--integrity-not-validated"
314
326
  to switch off foreign key constraint enforcement / validation.
315
327
 
316
328
  Options
@@ -335,7 +347,7 @@ optionProcessor.command('manageConstraints')
335
347
 
336
348
  optionProcessor.command('toCsn')
337
349
  .option('-h, --help')
338
- .option('-f, --flavor <flavor>', ['client', 'gensrc'])
350
+ .option('-f, --flavor <flavor>', ['client', 'gensrc', 'universal'])
339
351
  .option(' --with-localized')
340
352
  .help(`
341
353
  Usage: cdsc toCsn [options] <files...>
@@ -350,6 +362,7 @@ optionProcessor.command('toCsn')
350
362
  combination with additional "extend" or "annotate"
351
363
  statements, but not suitable for consumption by clients or
352
364
  backends
365
+ universal: in development (BETA)
353
366
 
354
367
  Internal options (for testing only, may be changed/removed at any time)
355
368
  --with-localized Add localized convenience views to the CSN output.
@@ -357,6 +370,7 @@ optionProcessor.command('toCsn')
357
370
 
358
371
  optionProcessor.command('parseCdl')
359
372
  .option('-h, --help')
373
+ .positionalArgument('<file>')
360
374
  .help(`
361
375
  Usage: cdsc parseCdl [options] <file>
362
376
 
@@ -369,14 +383,17 @@ optionProcessor.command('parseCdl')
369
383
 
370
384
  optionProcessor.command('explain')
371
385
  .option('-h, --help')
386
+ .positionalArgument('<message-id>')
372
387
  .help(`
373
388
  Usage: cdsc explain [options] <message-id>
374
389
 
375
390
  Explain the compiler message that has the given message-id.
376
391
  The explanation contains a faulty example and a solution.
377
392
 
393
+ Use \`explain list\` to list all available messages.
394
+
378
395
  Options
379
- -h, --help Show this help text
396
+ -h, --help Show this help text
380
397
  `);
381
398
 
382
399
  module.exports = {
@@ -7,8 +7,11 @@
7
7
  "prefer-template": "error",
8
8
  "no-trailing-spaces": "error",
9
9
  "sonarjs/cognitive-complexity": "off",
10
+ "sonarjs/no-duplicate-string": ["off"],
11
+ "sonarjs/no-nested-template-literals": "off",
10
12
  "template-curly-spacing":["error", "never"],
11
- "complexity": ["warn", 30],
13
+ // Who cares - just very whiny and in the way
14
+ "complexity": "off",
12
15
  "max-len": "off",
13
16
  // We should enable this
14
17
  "no-shadow": "off"
@@ -8,8 +8,6 @@
8
8
 
9
9
  'use strict';
10
10
 
11
- const walker = require('../json/walker');
12
-
13
11
  /**
14
12
  * database name - uppercase if not quoted
15
13
  *
@@ -46,7 +44,7 @@ class DuplicateChecker {
46
44
  * Add an artifact to the "seen"-list
47
45
  *
48
46
  * @param {string} name Persistence name of the artifact
49
- * @param {CSN.Location} location CSN location of the artifact
47
+ * @param {CSN.Location|CSN.Path} location CSN location of the artifact
50
48
  * @param {string} modelName CSN artifact name
51
49
  */
52
50
  addArtifact( name, location, modelName ) {
@@ -87,13 +85,13 @@ class DuplicateChecker {
87
85
  * @param {CSN.Options} options Options used for the compilation
88
86
  */
89
87
  check(error, options = null) {
90
- walker.forEach(this.seenArtifacts, (artifactName, artifacts) => {
88
+ forEach(this.seenArtifacts, (artifactName, artifacts) => {
91
89
  if (artifacts.length > 1) {
92
90
  artifacts.slice(1).forEach((artifact) => { // report all colliding artifacts, except the first one
93
91
  const collidesWith = this.seenArtifacts[artifactName].find( art => art !== artifact );
94
92
  let namingMode;
95
93
  if (options)
96
- namingMode = options.toHana ? options.toHana.names : options.toSql.names;
94
+ namingMode = options.sqlMapping;
97
95
  else
98
96
  namingMode = 'plain';
99
97
 
@@ -106,7 +104,7 @@ class DuplicateChecker {
106
104
  });
107
105
  }
108
106
  artifacts.forEach((artifact) => {
109
- walker.forEach(artifact.elements, (elementName, elements) => {
107
+ forEach(artifact.elements, (elementName, elements) => {
110
108
  if (elements.length > 1) {
111
109
  elements.forEach((element) => { // report all colliding elements
112
110
  error(null,
@@ -123,4 +121,9 @@ class DuplicateChecker {
123
121
  }
124
122
  }
125
123
 
124
+ function forEach(obj, callback) {
125
+ for (const key in obj)
126
+ callback(key, obj[key]);
127
+ }
128
+
126
129
  module.exports = DuplicateChecker;