Skip to content

[Version: 2.1.2] issue deleting draft entity with a key that is not called ID #209

@franksgit

Description

@franksgit

Describe the bug
I am having a draft enabled entity Books that has a key bookId (i.e. not ID) that contains a composition of Attachments. When creating a draft of Books and then try to delete this draft I am getting and error:

Error: "up__ID" not found in the elements of "AdminService.Books.attachments.drafts"

at stepNotFoundInCombinedElements (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:794:13)
at /home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:501:11
at Array.forEach ()
at inferArg (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:441:13)
at processToken (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:307:11)
at Array.forEach ()
at walkTokenStream (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:311:19)
at inferQueryElements (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:280:16)
at infer (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/infer/index.js:71:22)
at cqn4sql (/home/user/projects/00_test/00_test/node_modules/@cap-js/db-service/lib/cqn4sql.js:80:14)

The behavior only occurs if I am binding the service to a real instance of the objectstore and thus do
cds watch --profile hybrid

I can delete the draft of Books:

  • when I am doing a fully local testing (i.e. cds watch) even if the key is called "bookId"
    or
  • if I do define the key of Books as "ID" rather than "bookId" (even in cds watch --profile hybrid)

To Reproduce
You can check out this mini example: https://github.com/franksgit/issue_capjs_attachments
and follow the docu of README.md with the attached test/http examples

Note, that you must bind the service to a real objectstore instance to see the error. (i.e. do cds watch --profile hybrid)

Expected behavior
I am expecting that the deletion of draft instances also works for entities that have a key called something else than "ID".

[ ] is it a regression issue?

Screenshots

Image Image

Customer Info
Company: Capgemini

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions