UNPKG

@sap/cds-compiler

Version:

CDS (Core Data Services) compiler and backends

32 lines (29 loc) 824 B
'use strict'; /** * A path following an “exists” predicate must always end in an association. * * @param {object} parent * @param {string} prop * @param {Array} expression * @param {CSN.Path} path */ function existsMustNotStartWithDollarSelf( parent, prop, expression, path ) { for (let i = 0; i < expression?.length - 1; i++) { if (expression[i] === 'exists') { const next = expression[i + 1]; if (next.$scope === '$self') { const errorPath = path.concat([ prop, i ]); this.error('ref-unexpected-self', errorPath, { '#': 'exists', id: next.ref[0], name: 'exists', }); } } } } module.exports = { having: existsMustNotStartWithDollarSelf, where: existsMustNotStartWithDollarSelf, xpr: existsMustNotStartWithDollarSelf, };