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(cqn4sql): be robust against $self.<element> references #471

Merged
merged 4 commits into from
Feb 20, 2024
Merged

Conversation

patricebender
Copy link
Member

if a ref of length > 1, has ref[0] === 'self', the $self can just be ignored. $self comparisons have only special semantics if compared to an association. With this change, we become more robust in that regard and do not prepend wrong table aliases for the case $self.<assoc>.<element> - in that case, we must ensure that the alias of the association is used and not the alias of the entity. Follow up #468

if a `ref` of length > 1, has `ref[0] === 'self'`, the `$self`
can just be ignored. `$self` comparisons have only special semantics
if compared to an association. With this change, we become more robust
in that regard and do not prepend wrong table aliases for the case
`$self.<assoc>.<element>` - in that case, we must ensure that the alias
of the association is used and not the alias of the entity.
Comment on lines 1817 to 1822
if (lhs.ref[0] === '$self') { // $self in ref of length > 1
// if $self is followed by association, the alias of the association must be used
if (lhs.$refLinks[1].definition.isAssociation) result[i].ref.splice(0, 1)
// otherwise $self points to the entity itself
else result[i].ref.splice(0, 1, targetSideRefLink.alias)
} else if (lhs.ref.length > 1) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relevant changes, other stuff is formatting

@patricebender patricebender enabled auto-merge (squash) February 20, 2024 12:30
@patricebender patricebender merged commit 2921b0e into main Feb 20, 2024
4 of 6 checks passed
@patricebender patricebender deleted the self branch February 20, 2024 12:34
@cap-bots cap-bots mentioned this pull request Feb 20, 2024
patricebender added a commit that referenced this pull request Feb 21, 2024
🤖 I have created a release *beep* *boop*
---


<details><summary>db-service: 1.6.3</summary>

##
[1.6.3](db-service-v1.6.2...db-service-v1.6.3)
(2024-02-20)


### Fixed

* **`cqn4sql`:** be robust against `$self.&lt;element&gt;` references
([#471](#471))
([2921b0e](2921b0e))
* **cds.infer:** Always use srv.model
([#451](#451))
([41cf4a2](41cf4a2))
* Throw 'new Error' instead of string on $search with multiple words
([#472](#472))
([51be94d](51be94d))
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: Patrice Bender <patrice.bender@sap.com>
@cap-bots cap-bots mentioned this pull request Jul 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants