Fix issue in is_val_equal_to_tenant
leading to redundant DB calls
#215
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.
As described in this issue we want to avoid making extra queries when using related managers.
The proposed solution avoids making extra DB calls by comparing the tenant field of
val
againstself.tenant_value
instead of comparingval
with the whole tenant object.Notes
is_val_equal_to_tenant
is a bit misleading/bad naming as this function actually checks for in-equality.I think we should do one of the following-
is_not_equal_to_tenant
and keep the same implementationI can update this PR if you prefer one of these options, I wanted to keep this PR on the issue point and avoid cosmetics so didn't add these changes in advance.