From 85ab397fd1dc9831bac65a94f8996d40c3e82984 Mon Sep 17 00:00:00 2001 From: Siarhei Murkou Date: Sat, 31 Aug 2024 21:37:14 +0300 Subject: [PATCH] Fix CDS prop nullability if `@mandatory` is used --- lib/resolution/resolver.js | 2 +- lib/visitor.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/resolution/resolver.js b/lib/resolution/resolver.js index 23322e4..4afb2d9 100644 --- a/lib/resolution/resolver.js +++ b/lib/resolution/resolver.js @@ -452,7 +452,7 @@ class Resolver { isArray: false, isNotNull: element?.isRefNotNull !== undefined ? element?.isRefNotNull - : element?.key || element?.notNull || cardinality > 1, + : element?.key || element?.notNull || element?.['@mandatory'] || cardinality > 1, } if (element?.type === undefined) { diff --git a/lib/visitor.js b/lib/visitor.js index 3507e6a..47a3b58 100644 --- a/lib/visitor.js +++ b/lib/visitor.js @@ -243,7 +243,7 @@ class Visitor { LOG.error(`Attempting to generate a foreign key reference called '${foreignKey}' in type definition for entity ${fq}. But a property of that name is already defined explicitly. Consider renaming that property.`) } else { const kelement = Object.assign(Object.create(originalKeyElement), { - isRefNotNull: !!element.notNull || !!element.key + isRefNotNull: !!element.notNull || !!element['@mandatory'] || !!element.key }) this.visitElement(foreignKey, kelement, file, buffer) }