Resolves ENGA-923 "Modify django-bigquery-exporter base to include decorator for custom_field" #6
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ENGA-923
Non-technical Context
Replacing the custom_fields array with a single fields array and a decorator to identify custom methods allows for a cleaner implementation and higher visibility for custom fields
Technical Context
The current decorator implementation is very bare bones. It just adds a custom attribute, "is_custom_field" to the function or method. This allows the
_process_queryset
method to check for the presence of the field, and determine whether to check the model or call the method.The decorator isn't strictly necessary in this implementation but it does reduce the risk of accidental naming collisions with existing model fields and it opens up the possibility of additional transformations or validation in the future. And it makes it easier to see what methods are custom fields at a glance.
While writing tests for the new decorator, I also refactored the existing tests to DRY up the test class by using a fixture rather than rewriting the test exporter class every time.
Developer
Reviewer