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 against self.tenant_value instead of comparing val 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-
Change the name to is_not_equal_to_tenant and keep the same implementation
Update the logic to check for equality, keep the current name and update the condition where this is used to be negated
I 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.
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.