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

Chore: Remove composition of many for Genres #427

Closed
wants to merge 1 commit into from
Closed

Conversation

etimr
Copy link
Contributor

@etimr etimr commented Jan 14, 2025

No description provided.

@etimr etimr requested a review from agoerler January 14, 2025 08:05
Copy link

cla-assistant bot commented Jan 14, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

1 similar comment
Copy link

cla-assistant bot commented Jan 14, 2025

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@etimr etimr requested a review from eugene-andreev January 14, 2025 08:06
@beckermarc
Copy link
Contributor

Did the approach with the projection not work out? I'd prefer if we could keep the composition on db-level.

@agoerler
Copy link
Contributor

Did the approach with the projection not work out? I'd prefer if we could keep the composition on db-level.

What is the purpose of this composition. If we decide that the Genres are not a single draft document but are editable individually then there should not be such a composition, I think.

@beckermarc
Copy link
Contributor

What is the purpose of this composition.

Maintaining the integrity of the hierarchy and avoiding gaps, by ensuring deep deletes. I think from a conceptual level on database the hierarchy is a large document. How the document is exposed via draft to users is a different question I think. So I think we should be able to expose individual nodes of the hierarchy as individual documents by excluding the composition on service-level.

@agoerler
Copy link
Contributor

by excluding the composition on service-level

or could we annotate it with @odata.draft.enclosed=false ?

@beckermarc
Copy link
Contributor

by excluding the composition on service-level

or could we annotate it with @odata.draft.enclosed=false ?

No, this is not supported. @odata.draft.enclosed is only supported on associations and mainly intended to turn within-document-associations into draft-enclosed ones, if we don't detect that out-of-the-box.

@etimr
Copy link
Contributor Author

etimr commented Jan 14, 2025

Did the approach with the projection not work out? I'd prefer if we could keep the composition on db-level.

It works as expected. I think the question is more about the use case. If I get it correctly, we don't want to delete a Genre, we will leave this scenario just for reading. For modifications we want to introduce two more entities to cover Vincent's examples. One as a composition of many child for Books (like a table of contents with chapters) and another one for modifying similar to Genres but without any relationships to it from another entities.

@beckermarc
Copy link
Contributor

Okay I still think it makes sense for scenarios where you want to enable editing of such hierarchies with drafts for individual nodes. If we however anyway won't use Genres as an example for write I don't see why we should remove the Composition that we had all the time. It makes sense from a modelling perspective.

BTW: Why not use Genres as an example for write with drafts for individual nodes? It would be a good fit from my perspective with the exclusion of the composition on service-level.

@etimr
Copy link
Contributor Author

etimr commented Jan 22, 2025

Decision regarding modeling of Genres in Bookshop:
books.cds

entity Genres : sap.common.CodeList {
    key ID       : UUID;
        parent   : Association to Genres;
        children : Composition of many Genres on children.parent = $self; 
} 

admin-service.cds

@odata.draft.enabled
entity GenreHierarchy as projection on my.Genres excluding {children};

Currently we are choosing to have a Cascade Delete with the easier possible way, Composition of many.

Depending on the relationships among the data, there are several possible scenarios:

  • Cascade Delete of children if parent is deleted (modeling)
  • Delete is allowed only for leafs, nodes with children are not deletable (custom logic)
  • Delete of the parent means reassigning grandparent as a parent for the children nodes (custom logic)

@etimr etimr closed this Jan 22, 2025
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.

4 participants