@sap/cds-compiler 6.7.3 → 6.8.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 (107) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/bin/cdsc.js +5 -5
  3. package/bin/cdsse.js +1 -1
  4. package/lib/api/main.js +9 -8
  5. package/lib/api/options.js +2 -1
  6. package/lib/api/validate.js +1 -1
  7. package/lib/base/error.js +2 -0
  8. package/lib/base/message-registry.js +7 -2
  9. package/lib/base/messages.js +2 -2
  10. package/lib/{optionProcessor.js → base/optionProcessor.js} +3 -3
  11. package/lib/base/{model.js → specialOptions.js} +16 -39
  12. package/lib/checks/arrayOfs.js +1 -1
  13. package/lib/checks/elements.js +1 -1
  14. package/lib/checks/enricher.js +2 -2
  15. package/lib/checks/featureFlags.js +54 -24
  16. package/lib/checks/foreignKeys.js +1 -1
  17. package/lib/checks/invalidTarget.js +1 -1
  18. package/lib/checks/managedInType.js +1 -1
  19. package/lib/checks/onConditions.js +1 -1
  20. package/lib/checks/queryNoDbArtifacts.js +1 -1
  21. package/lib/checks/validator.js +10 -14
  22. package/lib/compiler/builtins.js +1 -1
  23. package/lib/compiler/checks.js +3 -3
  24. package/lib/compiler/define.js +5 -2
  25. package/lib/{base → compiler}/dictionaries.js +2 -0
  26. package/lib/compiler/extend.js +2 -2
  27. package/lib/compiler/generate.js +2 -2
  28. package/lib/compiler/index.js +11 -3
  29. package/lib/compiler/kick-start.js +1 -1
  30. package/lib/compiler/populate.js +2 -2
  31. package/lib/compiler/resolve.js +4 -2
  32. package/lib/compiler/shared.js +35 -6
  33. package/lib/compiler/utils.js +2 -4
  34. package/lib/compiler/xpr-rewrite.js +1 -1
  35. package/lib/edm/annotations/edmJson.js +2 -4
  36. package/lib/edm/annotations/genericTranslation.js +2 -1
  37. package/lib/edm/csn2edm.js +3 -2
  38. package/lib/edm/edmAnnoPreprocessor.js +1 -1
  39. package/lib/edm/edmInboundChecks.js +2 -1
  40. package/lib/edm/edmPreprocessor.js +3 -3
  41. package/lib/edm/edmUtils.js +2 -2
  42. package/lib/gen/BaseParser.js +1 -12
  43. package/lib/gen/CdlGrammar.checksum +1 -1
  44. package/lib/gen/CdlParser.js +1068 -1067
  45. package/lib/json/from-csn.js +7 -2
  46. package/lib/json/to-csn.js +17 -2
  47. package/lib/main.js +3 -3
  48. package/lib/model/csnUtils.js +2 -2
  49. package/lib/modelCompare/compare.js +1 -1
  50. package/lib/modelCompare/utils/filter.js +1 -0
  51. package/lib/parsers/AstBuildingParser.js +40 -3
  52. package/lib/parsers/index.js +1 -1
  53. package/lib/render/manageConstraints.js +1 -1
  54. package/lib/render/toCdl.js +3 -3
  55. package/lib/render/toHdbcds.js +2 -2
  56. package/lib/render/toSql.js +7 -7
  57. package/lib/render/utils/common.js +9 -2
  58. package/lib/render/utils/sql.js +14 -5
  59. package/lib/render/utils/standardDatabaseFunctions.js +108 -99
  60. package/lib/sql-identifier.js +9 -1
  61. package/lib/{model → tool-lib}/enrichCsn.js +2 -2
  62. package/lib/{model → tool-lib}/revealInternalProperties.js +2 -1
  63. package/lib/transform/addTenantFields.js +1 -1
  64. package/lib/transform/db/applyTransformations.js +1 -1
  65. package/lib/transform/db/assertUnique.js +1 -1
  66. package/lib/transform/db/assocsToQueries/transformExists.js +1 -1
  67. package/lib/transform/db/backlinks.js +2 -2
  68. package/lib/transform/db/expansion.js +2 -2
  69. package/lib/transform/db/flattening.js +3 -4
  70. package/lib/transform/db/killAnnotations.js +1 -0
  71. package/lib/transform/db/processSqlServices.js +2 -1
  72. package/lib/transform/db/rewriteCalculatedElements.js +2 -2
  73. package/lib/transform/db/temporal.js +30 -5
  74. package/lib/transform/db/views.js +16 -20
  75. package/lib/transform/draft/db.js +1 -2
  76. package/lib/transform/effective/associations.js +1 -1
  77. package/lib/transform/effective/flattening.js +1 -1
  78. package/lib/transform/effective/main.js +19 -4
  79. package/lib/transform/effective/types.js +1 -1
  80. package/lib/transform/{odata/fioriTreeViews.js → fioriTreeViews.js} +48 -25
  81. package/lib/transform/forOdata.js +5 -5
  82. package/lib/transform/forRelationalDB.js +41 -9
  83. package/lib/transform/localized.js +2 -2
  84. package/lib/transform/odata/createForeignKeys.js +1 -1
  85. package/lib/transform/odata/flattening.js +2 -2
  86. package/lib/transform/odata/toFinalBaseType.js +3 -2
  87. package/lib/transform/odata/typesExposure.js +3 -2
  88. package/lib/transform/transformUtils.js +2 -2
  89. package/lib/transform/translateAssocsToJoins.js +2 -1
  90. package/lib/transform/tupleExpansion.js +4 -4
  91. package/lib/transform/universalCsn/universalCsnEnricher.js +7 -3
  92. package/lib/transform/universalCsn/utils.js +1 -1
  93. package/lib/{base → utils}/lazyload.js +9 -0
  94. package/lib/{base → utils}/node-helpers.js +2 -0
  95. package/lib/utils/objectUtils.js +29 -6
  96. package/lib/{base → utils}/optionProcessorHelper.js +16 -6
  97. package/package.json +2 -2
  98. /package/lib/{model → base}/cloneCsn.js +0 -0
  99. /package/lib/{model → base}/csnRefs.js +0 -0
  100. /package/lib/{model/api.js → base/model-api.js} +0 -0
  101. /package/lib/{api → base}/trace.js +0 -0
  102. /package/lib/{model → base}/xprAsTree.js +0 -0
  103. /package/lib/{inspect → tool-lib}/index.js +0 -0
  104. /package/lib/{inspect → tool-lib}/inspectModelStatistics.js +0 -0
  105. /package/lib/{inspect → tool-lib}/inspectPropagation.js +0 -0
  106. /package/lib/{inspect → tool-lib}/inspectUtils.js +0 -0
  107. /package/lib/{base → utils}/shuffle.js +0 -0
@@ -115,7 +115,7 @@
115
115
  * @returns {any} XSN property (e.g. string, object, ...)
116
116
  */
117
117
 
118
- const { dictAdd } = require('../base/dictionaries');
118
+ const { dictAdd } = require('../compiler/dictionaries');
119
119
  const { quotedLiteralPatterns } = require('../compiler/builtins');
120
120
  const { isAnnotationExpression } = require('../base/builtins');
121
121
  const { CompilerAssertion } = require('../base/error');
@@ -752,7 +752,7 @@ const schema = compileSchema( {
752
752
  type: namespace,
753
753
  },
754
754
  meta: { // meta information
755
- type: ignore, // TODO: should we test s/th here?
755
+ type: meta, // TODO: should we test s/th here?
756
756
  },
757
757
  version: { // deprecated top-level property
758
758
  type: ignore,
@@ -904,6 +904,11 @@ function arrayOf( fn, filter = undefined ) {
904
904
 
905
905
  // Generic functions, objects (std signature) --------------------------------
906
906
 
907
+ function meta( obj ) {
908
+ ignore( obj );
909
+ return obj;
910
+ }
911
+
907
912
  function ignore( obj ) {
908
913
  if (obj && typeof obj === 'object') {
909
914
  const array = (Array.isArray( obj )) ? obj : Object.values( obj );
@@ -12,7 +12,7 @@
12
12
  'use strict';
13
13
 
14
14
  const { locationString } = require('../base/messages');
15
- const { isBetaEnabled } = require('../base/model');
15
+ const { isBetaEnabled } = require('../base/specialOptions');
16
16
  const { pathName } = require('../compiler/utils');
17
17
  const { CompilerAssertion } = require('../base/error');
18
18
 
@@ -260,10 +260,25 @@ function compactModel( model, options = model.options || {} ) {
260
260
  break;
261
261
  }
262
262
 
263
+ const srcNames = Object.keys( srcDict );
264
+ const firstMeta = srcDict[srcNames[0]].meta;
265
+ const meta = srcNames.length === 1 && firstMeta ? { ...firstMeta } : undefined;
266
+ if (meta?.flavor)
267
+ delete meta.flavor; // not supported, compilerCsnFlavor is used instead
268
+ const flavorMap = {
269
+ client: 'inferred',
270
+ gensrc: 'xtended',
271
+ universal: 'universal',
272
+ };
273
+ const compilerCsnFlavor = flavorMap[options.csnFlavor] ||
274
+ (options.parseCdl ? 'parsed' : 'inferred');
263
275
  if (!options.testMode) {
264
- csn.meta = Object.assign( {}, model.meta, { creator } );
276
+ csn.meta = Object.assign( {}, model.meta, meta, { creator, compilerCsnFlavor } );
265
277
  csn.$version = csnVersion;
266
278
  }
279
+ else if (meta !== undefined) {
280
+ csn.meta = Object.assign( {}, meta );
281
+ }
267
282
  return csn;
268
283
  }
269
284
 
package/lib/main.js CHANGED
@@ -14,13 +14,13 @@
14
14
 
15
15
  'use strict';
16
16
 
17
- const lazyload = require('./base/lazyload')( module );
17
+ const lazyload = require('./utils/lazyload')( module );
18
18
 
19
- const { traceApi } = require('./api/trace');
19
+ const { traceApi } = require('./base/trace');
20
20
 
21
21
  const snapi = lazyload('./api/main');
22
22
  const csnUtils = lazyload('./model/csnUtils');
23
- const modelApi = lazyload('./model/api');
23
+ const modelApi = lazyload('./base/model-api');
24
24
  const messages = lazyload('./base/messages');
25
25
  const sqlIdentifier = lazyload('./sql-identifier');
26
26
  const keywords = lazyload( './base/keywords' );
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const { csnRefs, implicitAs, pathId } = require('./csnRefs');
3
+ const { csnRefs, implicitAs, pathId } = require('../base/csnRefs');
4
4
  const {
5
5
  transformExpression,
6
6
  transformAnnotationExpression,
@@ -13,7 +13,7 @@ const { isBuiltinType, isAnnotationExpression } = require('../base/builtins');
13
13
  const { ModelError, CompilerAssertion } = require('../base/error');
14
14
  const { typeParameters } = require('../compiler/builtins');
15
15
  const { forEach } = require('../utils/objectUtils');
16
- const { cloneAnnotationValue } = require('./cloneCsn');
16
+ const { cloneAnnotationValue } = require('../base/cloneCsn');
17
17
 
18
18
  // Low-level utility functions to work with compact CSN.
19
19
 
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const { makeMessageFunction } = require('../base/messages');
4
- const { setProp } = require('../base/model');
4
+ const { setProp } = require('../utils/objectUtils');
5
5
  const {
6
6
  forEachDefinition,
7
7
  forEachMember,
@@ -148,6 +148,7 @@ const defaultAllowedTypeChanges = {
148
148
  'cds.Integer': [ 'cds.Int32', 'cds.Int64', 'cds.Integer64' ],
149
149
  'cds.Integer64': [ 'cds.Int64' ],
150
150
  'cds.Int64': [ 'cds.Integer64' ],
151
+ 'cds.String': [ 'cds.LargeString' ],
151
152
  };
152
153
 
153
154
  const allowedTypeChanges = {
@@ -3,7 +3,7 @@
3
3
  const BaseParser = require( '../gen/BaseParser' );
4
4
 
5
5
  const { Location } = require( '../base/location' );
6
- const { dictAdd, dictAddArray } = require('../base/dictionaries');
6
+ const { dictAdd, dictAddArray } = require('../compiler/dictionaries');
7
7
  const { functionsWithoutParentheses } = require('./identifiers');
8
8
 
9
9
  const { pathName } = require('../compiler/utils');
@@ -39,7 +39,7 @@ const valueTokens = {
39
39
  true: true,
40
40
  };
41
41
  const valueTokensLength = Object.values( valueTokens ).length;
42
- // likewise, if expectedArray contains all the following tokens, replace them by 'Literal'
42
+ // if expectedArray contains all the following tokens, replace them by 'Literal'
43
43
  const literalTokens = {
44
44
  Number: true,
45
45
  QuotedLiteral: true,
@@ -51,6 +51,29 @@ const literalTokens = {
51
51
  };
52
52
  const literalTokensLength = Object.values( literalTokens ).length;
53
53
 
54
+ // if expectedArray contains all the following tokens, replace them by 'Comparison'
55
+ const comparisonTokens = {
56
+ '=': true,
57
+ '<>': true,
58
+ '>': true,
59
+ '>=': true,
60
+ '<': true,
61
+ '<=': true,
62
+ '!=': true,
63
+ '==': true,
64
+ };
65
+ const comparisonTokensLength = Object.values( comparisonTokens ).length;
66
+
67
+ // if expectedArray contains all the following tokens, replace them by 'Operator'
68
+ const operatorTokens = {
69
+ '+': true,
70
+ '-': true,
71
+ '*': true,
72
+ '/': true,
73
+ '||': true,
74
+ };
75
+ const operatorTokensLength = Object.values( operatorTokens ).length;
76
+
54
77
  const extensionDicts = {
55
78
  elements: true, enum: true, params: true, returns: true,
56
79
  };
@@ -127,6 +150,19 @@ class AstBuildingParser extends BaseParser {
127
150
  if (withoutLiteralTokens.length + literalTokensLength === array.length)
128
151
  array = [ 'Literal', ...withoutLiteralTokens ];
129
152
  }
153
+
154
+ const withoutComparisonTokens = raw ? array : array.filter(
155
+ tok => comparisonTokens[tok] !== true
156
+ );
157
+ if (withoutComparisonTokens.length + comparisonTokensLength === array.length)
158
+ array = [ 'Comparison', ...withoutComparisonTokens ];
159
+
160
+ const withoutOperatorTokens = raw ? array : array.filter(
161
+ tok => operatorTokens[tok] !== true
162
+ );
163
+ if (withoutOperatorTokens.length + operatorTokensLength === array.length)
164
+ array = [ 'Operator', ...withoutOperatorTokens ];
165
+
130
166
  return array.map( tok => this.antlrName( tok ) )
131
167
  .sort( (a, b) => (tokenPrecedence(a) < tokenPrecedence(b) ? -1 : 1) );
132
168
  }
@@ -328,7 +364,8 @@ class AstBuildingParser extends BaseParser {
328
364
  // TODO: as leanCondition ? `order` should probably appear in the message for
329
365
  // test3/Compiler/GrammarRobustness/InvalidSelectInWhere.err.cds
330
366
  orderByLimitRestriction( _arg, mode ) {
331
- if (mode && (!this.$allowOrderByLimit || this.precPost_( mode, 0 )))
367
+ if (mode &&
368
+ (!this.$allowOrderByLimit && mode !== 'M' || this.precPost_( mode, 0 )))
332
369
  return true;
333
370
  this.$allowOrderByLimit = !mode;
334
371
  return false;
@@ -2,7 +2,7 @@
2
2
 
3
3
  'use strict';
4
4
 
5
- const lazyload = require('../base/lazyload')( module );
5
+ const lazyload = require('../utils/lazyload')( module );
6
6
  const { CompilerAssertion } = require( '../base/error' );
7
7
  const { createMessageFunctions } = require( '../base/messages' );
8
8
  const { XsnSource } = require('../compiler/xsn-model');
@@ -11,7 +11,7 @@ const { transformForRelationalDBWithCsn } = require('../transform/forRelationalD
11
11
  const {
12
12
  renderReferentialConstraint, getIdentifierUtils,
13
13
  } = require('./utils/sql');
14
- const { sortCsn } = require('../model/cloneCsn');
14
+ const { sortCsn } = require('../base/cloneCsn');
15
15
 
16
16
  /**
17
17
  * Used only by `cdsc manageConstraints`.
@@ -20,14 +20,14 @@ const { escapeString, hasUnpairedUnicodeSurrogate } = require('./utils/stringEsc
20
20
  const { checkCSNVersion } = require('../json/csnVersion');
21
21
  const { normalizeTypeRef, forEachDefinition } = require('../model/csnUtils');
22
22
  const enrichUniversalCsn = require('../transform/universalCsn/universalCsnEnricher');
23
- const { isBetaEnabled } = require('../base/model');
23
+ const { isBetaEnabled } = require('../base/specialOptions');
24
24
  const { ModelError, CompilerAssertion } = require('../base/error');
25
25
  const { typeParameters, specialFunctions } = require('../compiler/builtins');
26
26
  const { isAnnotationExpression } = require('../base/builtins');
27
27
  const { forEach } = require('../utils/objectUtils');
28
28
  const { isBuiltinType } = require('../base/builtins');
29
- const { cloneFullCsn } = require('../model/cloneCsn');
30
- const { getKeysDict, implicitAs } = require('../model/csnRefs');
29
+ const { cloneFullCsn } = require('../base/cloneCsn');
30
+ const { getKeysDict, implicitAs } = require('../base/csnRefs');
31
31
  const { undelimitedIdentifierRegex } = require('../parsers/identifiers');
32
32
  const { getNormalizedQuery } = require('../model/csnUtils');
33
33
  const {
@@ -18,13 +18,13 @@ const {
18
18
  renderReferentialConstraint,
19
19
  } = require('./utils/sql');
20
20
  const DuplicateChecker = require('./DuplicateChecker');
21
- const { isDeprecatedEnabled } = require('../base/model');
21
+ const { isDeprecatedEnabled } = require('../base/specialOptions');
22
22
  const { checkCSNVersion } = require('../json/csnVersion');
23
23
  const { timetrace } = require('../utils/timetrace');
24
24
 
25
25
  const { smartId, delimitedId } = require('../sql-identifier');
26
26
  const { ModelError, CompilerAssertion } = require('../base/error');
27
- const { pathId } = require('../model/csnRefs');
27
+ const { pathId } = require('../base/csnRefs');
28
28
 
29
29
  const $PROJECTION = '$projection';
30
30
  const $SELF = '$self';
@@ -24,15 +24,15 @@ const {
24
24
  const DuplicateChecker = require('./DuplicateChecker');
25
25
  const { checkCSNVersion } = require('../json/csnVersion');
26
26
  const { timetrace } = require('../utils/timetrace');
27
- const { isBetaEnabled, isDeprecatedEnabled } = require('../base/model');
27
+ const { isBetaEnabled, isDeprecatedEnabled } = require('../base/specialOptions');
28
28
  const sqlIdentifiers = require('../sql-identifier');
29
- const { sortCsn } = require('../model/cloneCsn');
29
+ const { sortCsn } = require('../base/cloneCsn');
30
30
  const { manageConstraints, manageConstraint } = require('./manageConstraints');
31
31
  const { renderUniqueConstraintString, renderUniqueConstraintDrop, renderUniqueConstraintAdd } = require('./utils/unique');
32
32
  const { ModelError, CompilerAssertion } = require('../base/error');
33
- const { pathId } = require('../model/csnRefs');
33
+ const { pathId } = require('../base/csnRefs');
34
34
  const { transformExprOperators } = require('./utils/operators');
35
- const { exprAsTree, condAsTree } = require('../model/xprAsTree');
35
+ const { exprAsTree, condAsTree } = require('../base/xprAsTree');
36
36
 
37
37
  class SqlRenderEnvironment {
38
38
  indent = '';
@@ -114,7 +114,7 @@ function toSqlDdl( csn, options, messageFunctions ) {
114
114
  const {
115
115
  error, warning, info, throwWithAnyError,
116
116
  } = messageFunctions;
117
- const { quoteSqlId, prepareIdentifier, renderArtifactName } = getIdentifierUtils(csn, options);
117
+ const { quoteSqlId, prepareIdentifier, renderArtifactName } = getIdentifierUtils(csn, options, warning);
118
118
  const reportedMissingReplacements = Object.create(null);
119
119
 
120
120
  const exprRenderer = createExpressionRenderer({
@@ -795,7 +795,7 @@ function toSqlDdl( csn, options, messageFunctions ) {
795
795
  return '';
796
796
  env = env.withSubPath([ 'elements', elementName ]);
797
797
  const isPostgresAlterColumn = env.alterMode && env.changeType === 'migration' && options.sqlDialect === 'postgres';
798
- const quotedElementName = quoteSqlId(elementName);
798
+ const quotedElementName = quoteSqlId(elementName, env.path);
799
799
  if (duplicateChecker)
800
800
  duplicateChecker.addElement(quotedElementName, elm.$location, elementName);
801
801
 
@@ -1451,7 +1451,7 @@ function toSqlDdl( csn, options, messageFunctions ) {
1451
1451
  * @returns {string} Rendered type
1452
1452
  */
1453
1453
  function renderBuiltinType( typeName ) {
1454
- const types = cdsToSqlTypes[options.sqlDialect];
1454
+ const types = cdsToSqlTypes[options.sqliteRealAffinityForDecimal && options.sqlDialect === 'sqlite' ? 'sqlitereal' : options.sqlDialect];
1455
1455
  const result = types?.[typeName] || cdsToSqlTypes.standard[typeName];
1456
1456
  if (!result && options.testMode)
1457
1457
  throw new CompilerAssertion(`Expected to find a type mapping for ${ typeName }`);
@@ -21,7 +21,7 @@ const {
21
21
  hasValidSkipOrExists, forEachDefinition, getNamespace, getUnderscoredName,
22
22
  } = require('../../model/csnUtils');
23
23
 
24
- const { implicitAs } = require('../../model/csnRefs');
24
+ const { implicitAs } = require('../../base/csnRefs');
25
25
 
26
26
  /**
27
27
  * Render the given function
@@ -294,7 +294,7 @@ const cdsToSqlTypes = {
294
294
  'cds.Binary': 'BINARY_BLOB',
295
295
  'cds.hana.BINARY': 'BINARY_BLOB',
296
296
  'cds.hana.SMALLDECIMAL': 'SMALLDECIMAL',
297
- 'cds.Vector': 'BINARY_BLOB', // Not supported; see #11725
297
+ 'cds.Vector': 'FLOAT32',
298
298
  'cds.Map': 'JSON_TEXT', // '_TEXT' suffix required for text affinity
299
299
  },
300
300
  plain: {
@@ -325,6 +325,13 @@ const cdsToSqlTypes = {
325
325
  },
326
326
  };
327
327
 
328
+ cdsToSqlTypes.sqlitereal = {
329
+ ...cdsToSqlTypes.sqlite,
330
+ 'cds.Decimal': 'REAL_DECIMAL',
331
+ 'cds.DecimalFloat': 'REAL_DECIMAL',
332
+ 'cds.hana.SMALLDECIMAL': 'REAL_SMALLDECIMAL',
333
+ };
334
+
328
335
  // Type mapping from cds type names to HDBCDS type names:
329
336
  // Only those types, that need mapping, are listed.
330
337
  const cdsToHdbcdsTypes = {
@@ -3,9 +3,9 @@
3
3
  'use strict';
4
4
 
5
5
  const { getResultingName } = require('../../model/csnUtils');
6
- const { smartId, delimitedId } = require('../../sql-identifier');
6
+ const { smartId, delimitedId, sqlDialects } = require('../../sql-identifier');
7
7
  const { ModelError } = require('../../base/error');
8
- const { setProp } = require('../../base/model');
8
+ const { setProp } = require('../../utils/objectUtils');
9
9
 
10
10
  /**
11
11
  * Render a given referential constraint as part of a SQL CREATE TABLE statement, or as .hdbconstraint artefact.
@@ -66,10 +66,12 @@ function renderReferentialConstraint( constraint, indent, toUpperCase, csn, opti
66
66
  /**
67
67
  * Get functions which can be used to prepare and quote SQL identifiers based on the options provided.
68
68
  *
69
+ * @param {CSN.Model} csn
69
70
  * @param {CSN.Options} options
71
+ * @param {function} warning
70
72
  * @returns quoteSqlId and prepareIdentifier function
71
73
  */
72
- function getIdentifierUtils( csn, options ) {
74
+ function getIdentifierUtils( csn, options, warning ) {
73
75
  return { quoteSqlId, prepareIdentifier, renderArtifactName };
74
76
  /**
75
77
  * Return 'name' with appropriate "-quotes.
@@ -81,10 +83,17 @@ function getIdentifierUtils( csn, options ) {
81
83
  * Complain about names that collide with known SQL keywords or functions
82
84
  *
83
85
  * @param {string} name Identifier to quote
86
+ * @param {CSN.Path} path Path to the identifier in the CSN model (for warnings)
84
87
  * @returns {string} Quoted identifier
85
88
  */
86
- function quoteSqlId( name ) {
89
+ function quoteSqlId( name, path ) {
87
90
  name = prepareIdentifier(name);
91
+ const s = sqlDialects[options.sqlDialect];
92
+ if ( warning && name.length > s.maxIdentifierLength ) {
93
+ warning( 'query-invalid-identifier',
94
+ path,
95
+ { name: options.sqlDialect, number: s.maxIdentifierLength });
96
+ }
88
97
 
89
98
  switch (options.sqlMapping) {
90
99
  case 'plain':
@@ -139,7 +148,7 @@ function getIdentifierUtils( csn, options ) {
139
148
  * @returns {string} Artifact name
140
149
  */
141
150
  function renderArtifactName( artifactName ) {
142
- return quoteSqlId(getResultingName(csn, options.sqlMapping, artifactName));
151
+ return quoteSqlId(getResultingName(csn, options.sqlMapping, artifactName), [ 'definitions', artifactName ] );
143
152
  }
144
153
  }
145
154