@sap/cds-compiler
Advanced tools
Comparing version 4.2.2 to 4.2.4
@@ -10,2 +10,8 @@ # ChangeLog for cds compiler and backends | ||
## Version 4.2.4 - 2023-09-14 | ||
### Fixed | ||
- OData: For compatibility with the Java runtime, don't prepend table aliases to column aliases unless necessary. | ||
## Version 4.2.2 - 2023-08-31 | ||
@@ -12,0 +18,0 @@ |
@@ -49,2 +49,3 @@ // module- and csn/XSN-independent definitions | ||
noKeyPropagationWithExpansions: true, | ||
ignoreSpecifiedQueryElements: true, | ||
} | ||
@@ -51,0 +52,0 @@ |
@@ -10,3 +10,3 @@ 'use strict'; | ||
} = require('../../model/csnUtils'); | ||
const { implicitAs, columnAlias } = require('../../model/csnRefs'); | ||
const { implicitAs, columnAlias, pathId } = require('../../model/csnRefs'); | ||
const { setProp } = require('../../base/model'); | ||
@@ -43,5 +43,6 @@ const { forEach } = require('../../utils/objectUtils'); | ||
// while the OData CSN is still official | ||
const isComplexQuery = parent.from.join !== undefined; | ||
if (!options.toOdata) | ||
parent.columns = replaceStar(root, columns, parent.excluding, parent.from.join !== undefined); | ||
parent.columns = expand(parent.columns, path.concat('columns'), true); | ||
parent.columns = replaceStar(root, columns, parent.excluding, isComplexQuery); | ||
parent.columns = expand(parent.columns, path.concat('columns'), true, isComplexQuery); | ||
} | ||
@@ -517,5 +518,6 @@ }, | ||
* @param {boolean} [withAlias=false] Whether to "expand" the (implicit) alias as well. | ||
* @param {boolean} [isComplexQuery] | ||
* @returns {Array} New array - with all structured things expanded | ||
*/ | ||
function expand( thing, path, withAlias = false ) { | ||
function expand( thing, path, withAlias = false, isComplexQuery = false ) { | ||
const newThing = []; | ||
@@ -527,3 +529,3 @@ for (let i = 0; i < thing.length; i++) { | ||
if (_art && csnUtils.isStructured(_art)) | ||
newThing.push(...expandRef(_art, col, withAlias)); | ||
newThing.push(...expandRef(_art, col, withAlias, isComplexQuery)); | ||
else | ||
@@ -603,5 +605,6 @@ newThing.push(col); | ||
* @param {boolean} withAlias Whether to add an explicit flattened alias to the expanded columns/references. | ||
* @param {boolean} [isComplexQuery] | ||
* @returns {Array} | ||
*/ | ||
function expandRef( art, root, withAlias ) { | ||
function expandRef( art, root, withAlias, isComplexQuery ) { | ||
return _expandStructCol(art, columnAlias(root), root.ref, ( currentRef, currentAlias) => { | ||
@@ -621,3 +624,9 @@ const obj = { ...root, ref: currentRef }; | ||
if (typeof root.$env === 'string') | ||
// The Java runtime, as of 2023-09-13, assumes that for _simple projections_, all references | ||
// are relative to the query source. To avoid breaking that assumption unless necessary, | ||
// we only add the table alias if: | ||
// - it is a complex query with possibly multiple available table aliases, or | ||
// - the transformation is not for OData (which is used by Java), or | ||
// - the first path step has the same name as the table alias (only one, as otherwise the query would be complex) | ||
if (typeof root.$env === 'string' && (isComplexQuery || options.transformation !== 'odata' || root.$env === pathId(obj.ref[0]))) | ||
obj.ref = [ root.$env, ...obj.ref ]; | ||
@@ -624,0 +633,0 @@ |
{ | ||
"name": "@sap/cds-compiler", | ||
"version": "4.2.2", | ||
"version": "4.2.4", | ||
"description": "CDS (Core Data Services) compiler and backends", | ||
@@ -5,0 +5,0 @@ "homepage": "https://cap.cloud.sap/", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4612530
91989