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

Improve virtual relation API #215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

daanvdk
Copy link
Collaborator

@daanvdk daanvdk commented May 30, 2022

This PR changes some small stuff about relations/virtual relations that should fix some crashes and make some bugs apparent.

  • The related ids returned internally are now more well formed, the related ids used to be a defauldict(list) per relation for normal relations and whatever you returned for virtual relations. It is now always a dict containing exactly the requested ids as keys and lists as values.
  • Relations are now only added to the model data if it actually appeared in the relation tree at a place where it was requested.
  • There is a check now that it will give an error if a singular relation has multiple ids, previously it would just take the first one.

So actual results of this:

  • API responses make a bit more sense, beforehand it would appear that some models had no related ids but in reality they were just not requested but were annotated.
  • Virtual annotation return values are handled more relaxed, before it would often happen that you write the function, it seems correct and then in production it would crash on some missing key for specific situations.
  • Singular virtual annotations will crash when returning multiple values which probably was a bug. This will now be clear instead of silently hidden by the system.

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.

1 participant