citusdata / django-multitenant

Python/Django support for distributed multi-tenant databases like Postgres+Citus
MIT License
707 stars 116 forks source link

Fix issue in `is_val_equal_to_tenant` leading to redundant DB calls #215

Open GuySharir opened 2 months ago

GuySharir commented 2 months ago

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-

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.

GuySharir commented 2 months ago

@microsoft-github-policy-service agree company="Twingate"