Repository navigation
fix: Properly relink csn clone - #207
Merged
Merged
Conversation
tim-sh
reviewed
Oct 30, 2026
The previous test called toOpenApi() with a linked model and asserted it returned a result, but this passed even on the unfixed code (compiler v6 doesn't throw on unlinked CSN — only v7+ does). Replace with a spy on cds.compile.to.edm that captures the prototype of the CSN it receives. With the fix the cloned CSN is re-linked before EDM compilation (LinkedCSN); without it a plain Object enters EDM, which breaks cds-compiler v7+ on draft entity projections. Also move @odata.draft.enabled onto the base entity (the actual scenario from the bug report) rather than on the service.
tim-sh
approved these changes
Nov 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #204
In the latest version, we introduced a call to
cds.cloneas very first step, to make sure we do not modify the passed-in CSN by reference.As
cds.cloneusesstructuredCloneunder the hood, it destroys the prototype chain of the clone, which causes problems downstream when a LinkedCSN is being passed in.We can remedy this by linking the CSN again after the clone, if the user passed in a LinkedCSN.
Reproduction can be found in cap/sherlock/issues/903
(confirmed the fix addresses the problem)
Don't merge yet. We will discuss fixing this problem directly withincds.clone, instead of patching around it on the call site.Discussed: call site is reponsible for restoring linked properties.