Skip to content

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

@Merkur39

Description

@Merkur39

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

Metadata

Metadata

Assignees

Labels

discussionDiscuss about a particular subject to take a decisionenhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions