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

[#243] Fix expand query parameter #286

Merged
merged 6 commits into from
Nov 22, 2024
Merged

Conversation

SonnyBA
Copy link
Contributor

@SonnyBA SonnyBA commented Nov 20, 2024

Fixes #243

Changes

Shows given expand query parameter results even when these are empty or null.

@SonnyBA SonnyBA force-pushed the issue/#243-fix-expand-param branch from 03821ea to 8e27f8e Compare November 20, 2024 10:11
@SonnyBA SonnyBA force-pushed the issue/#243-fix-expand-param branch from 8e27f8e to 6137dd5 Compare November 20, 2024 10:14
@SonnyBA SonnyBA marked this pull request as ready for review November 20, 2024 10:18
@SonnyBA SonnyBA self-assigned this Nov 20, 2024
if child.many:
results.setdefault(child.label, []).append(child_result)
child_results = results.setdefault(child.label, [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Am I wrong or is child_results not used for anything? We populate the list but we don't return it or append it to results

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The setdefault call for the results dictionary ensures that the child.label key exists with the value of a list. It also returns said list which will be used later on (if child_result has a value set).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I get this right, you are mutating the results because child_results has a reference to it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you make this a bit more readable? Because this does make it quite difficult to comprehend what is happening.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't remove the setdefault usage as I think it handles various things through a single method call (setting the value if it is not present, retrieving its content). I did add some type hints in case people are not familiar with the method. The nested if statements were also removed to make things more readable.

Comment on lines 178 to 179
data = None
id = str(uuid4())
Copy link
Contributor

@bart-maykin bart-maykin Nov 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why we need to fill id when there is no object? From what I can quickly see locally this isn't necessary.

@SonnyBA SonnyBA requested a review from bart-maykin November 20, 2024 14:25
@SonnyBA SonnyBA merged commit 3300c91 into master Nov 22, 2024
17 checks passed
@SonnyBA SonnyBA deleted the issue/#243-fix-expand-param branch November 22, 2024 11:45
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.

Presence of _expand key in Partij depends on number of elements in expanded key
2 participants