Automatically create nested R object rules if required#1
Automatically create nested R object rules if required#1philipstarkey wants to merge 1 commit intoBrightpathProgress:masterfrom
Conversation
This Fixes daisylb#22 `R` rules that traverse many-to-one or many-to-many relationships are now broken up automatically within `R.check()` into multiple, chained `R` rules. Tests to confirm both the original nested R syntax, and a the new unnested syntax, have been added.
|
This almost certainly needs improvement given my increased familiarity with bridgekeeper. I probably need to add some additional tests as I think there may be subtleties in manager attribute names vs query relations when traversing reverse many-to-many/one relationships (possibly when there are custom related_name attributes on the model field...something like that anyway) |
| for i, key_fragment in enumerate(fragments): | ||
| # Catch a many-to-many or many-to-one traversal and split it | ||
| # across multiple Rules | ||
| if not hasattr(lhs.__class__, "_meta"): |
There was a problem hiding this comment.
I suspect there is a better way to detect this (like possibly even just if isinstance(lhs, Manager): as is used further down
Yep. I've run into lots of weird inconsistencies with this. |
This Fixes daisylb#22
Rrules that traverse many-to-one or many-to-many relationships are now broken up automatically withinR.check()into multiple, chainedRrules.Tests to confirm both the original nested R syntax, and a the new unnested syntax, have been added.