Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CDS prop nullability if @mandatory is used #315

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/resolution/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@
if (parts.length <= 1) return []

/**
* @param {string} property

Check warning on line 162 in lib/resolution/resolver.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @param "property" description
* @param {import('../typedefs').resolver.EntityCSN} entity

Check warning on line 163 in lib/resolution/resolver.js

View workflow job for this annotation

GitHub Actions / lint

Missing JSDoc @param "entity" description
*/
const isPropertyOf = (property, entity) => property && Object.hasOwn(entity?.elements ?? {}, property)

Expand Down Expand Up @@ -452,7 +452,7 @@
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) {
Expand Down
2 changes: 1 addition & 1 deletion lib/visitor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Loading