Closed ledburyb closed 4 years ago
Hi Ben,
thank you for the issue and the PR, I will review all of this during this week !
Hi Louise,
Sounds good. The PR is a bit messy, and mostly just to see if we can agree on changes my team needs or if we should just carry on with our own fork. You can message me on the citus slack channel if you want to discuss anything we've done and why.
Hi Ben,
I'm looking into this issue and can't reproduce it. Could you by any chance share with me the CampaignEmailOptions
model?
Thanks
@louiseGrandjonc - I'm struggling a little with your test setup, but I've added a failing test case which I believe demonstrates the issue.
The way I resolved this in my fork was to move the join constraint into the get_joining_columns
method instead (https://github.com/MachineLabsLtd/django-multitenant/blob/master/django_multitenant/fields.py#L45), therefore ensuring it's part of all subqueries. I then simplified the get_extra_restrictions_check
: (https://github.com/MachineLabsLtd/django-multitenant/blob/master/django_multitenant/fields.py#L98).
I'm not sure if this approach has unintended downsides but it doesn't seem to have caused any problems in our project as yet.
Example error:
I've traced this back to https://github.com/citusdata/django-multitenant/blob/master/django_multitenant/fields.py#L72. This code is assuming that both alias and related_alias have a value which isn't true for this kind of exclude query.
This doesn't seem particularly easy to fix but I would suggest at least catching this condition and raising a more useful error:
e.g.