cancel
Showing results for 
Search instead for 
Did you mean: 

CAP OData draft handling invalidates one-to-many relationship

frankmeertens
Explorer
0 Kudos

The latest update of the CAP framework changed the behavior of 1:N navigation from an entity annotated with draft handling. Wondering if someone has experienced similar issue since latest update.

Below is a replication of the issue:

Data model: Authors to Books 1:N

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

entity Authors {
  key ID    : Integer;
      name  : String;
      books : Association to many Books
                on books.author = $self;
}

Service model: With Draft enabled, a query to expand the navigation remains empty. With Draft disabled, the navigation works. Prior to the latest update, this was working.

service CatalogService {

    @readonly
    entity Books   as projection on my.Books;

    // @odata.draft.enabled
    entity Authors as projection on my.Authors;
}

The OData request to test is http://localhost:4004/catalog/Authors?$expand=books

The output expected looks like this:

{
  "@odata.context": "$metadata#Authors(books())",
  "value": [
    {
      "ID": 1,
      "name": "John",
      "books": [
        { "ID": 1, "title": "Wuthering Heights", "stock": 100, "author_ID": 1 },
        { "ID": 2, "title": "Jane Eyre", "stock": 500, "author_ID": 1 }
      ]
    },
    { "ID": 2, "name": "Petra", "books": [] }
  ]
}

Anyone else experiencing this issue?

Accepted Solutions (0)

Answers (1)

Answers (1)

frankmeertens
Explorer

Should someone else experience this issue, a fix will be forthcoming in the next minor release.