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: reject all path expressions w/o foreign keys #806

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

patricebender
Copy link
Member

reject all path expressions which navigate along a managed association which does not provide foreign keys. In this case, we can't construct join conditions, where exists subqueries or correlated subqueries for expands.

For a draft enabled model:

```
namespace my;

entity Books {
  key ID : Integer;
  title  : String;
  stock  : Integer;
  author : Association to Authors;
}

entity Authors {
  key ID : Integer;
  name   : String;
  alive  : Boolean;
}

service CatalogService {
    @odata.draft.enabled
    @readonly entity Books as projection on my.Books;

    @readonly entity Authors as projection on my.Authors;
}
```

`my.Books` will have a field:
```
        "IsActiveEntity": {
          "type": "cds.Boolean",
          "key": true,
          "default": {
            "val": true
          },
          "@UI.Hidden": true
        },
```

which is marked as virtual by the lean draft implementation.
This virtual key must not be part of the primary key matching
which is done for a path expression in a `UPDATE.where`:

https://github.com/cap-js/cds-dbs/blob/982b8b796da4b577c5641039d2036816209c0437/db-service/test/cqn4sql/UPDATE.test.js#L73-L97

TODO:

- [] test this
reject all path expressions which navigate along a managed association
which does not provide foreign keys. In this case, we can't construct
join conditions, where exists subqueries or correlated subqueries for expands.
@patricebender patricebender marked this pull request as draft September 11, 2024 15:17
Base automatically changed from patrice/draft to main September 12, 2024 07:24
@patricebender patricebender marked this pull request as ready for review September 13, 2024 13:02
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