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

[HasMany/HasOne] Do not spread empty relationships #1473

Open
Merkur39 opened this issue May 13, 2024 · 0 comments
Open

[HasMany/HasOne] Do not spread empty relationships #1473

Merkur39 opened this issue May 13, 2024 · 0 comments
Assignees
Labels
discussion Discuss about a particular subject to take a decision enhancement New feature or request

Comments

@Merkur39
Copy link
Member

Merkur39 commented May 13, 2024

Today, these 2 classes have the same dehydrate method, which returns the document without the Associations attributes, and hydrates the document's relationships attribute with the relationships defined in the app's schema.

The default is that even if there are no relationships, the document has X(number of relationships defined in the app schema) objects added to its relationships attribute, and is registered in the DB as such.

It would probably be wiser not to add relationships that have no data?

This was highlighted during a development on cozy-contacts, where we needed to dehydrate the document.
https://github.com/cozy/cozy-contacts/blob/131c50c17c66171ba6e7c0cc3997b88abac259b1/src/components/ContactCard/ContactForm/helpers.js#L174-L191

@Merkur39 Merkur39 added enhancement New feature or request discussion Discuss about a particular subject to take a decision labels May 13, 2024
@Merkur39 Merkur39 self-assigned this May 13, 2024
@Merkur39 Merkur39 changed the title [HasMany/HasOne] Optimize dehydrate method [HasMany/HasOne] Do not spread empty relationships May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discuss about a particular subject to take a decision enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant