Rational
For now, the ModelStorage.read can be used to read direct field and related field from xxx2One or Reference. This API has been developed mainly for the client needs. But sometimes when integrating with other system, it will be more performant if we could read also other related fields.
Proposal
Allow to pass to ModelStorage.read xxx2Many related fields.
Here is an example of such call and the result:
read([id,…], {'name', 'language.name', 'addresses', 'addresses.country','addresses.country.code', 'addresses.subdivision'})
-> [{'id': 1, 'name': 'foo', 'language.name': 'French', 'addresses': [3, …], 'addresses.': [{'id': 3, 'country': 2, 'country.code': 'FR', 'subdivision': 5}, {…}, …]}, …]
So as soon as there are xxx2Many related fields, the result value for the field is a list of dictionary with the requested value plus always the id.
the name of the key is suffixed by a . to not collide with legacy result.
The API for xxx2One is not changed.
Of course the access rights must still be enforced.