Open dgm opened 11 years ago
I'm hesitant in adding such a bold thing as group_by to every query. Do we really know what kind of group by is needed? If we cannot be entirely sure, I'd rather have the app dev add it.
Another solution to this problem would be to use the results of with_permissions_to as a subselect for another query, which would keep the permissions part separate from the application domain part.
As another example that works:
Enrollment.where(child_id: 19447, id: Enrollment.with_permissions_to(:read))
It's a little clunky, but this does yield the correct results.
Given a rule such as:
@@@ has_permission_on :children, :to => :read do if_attribute :enrollments => {:session => {:yearly_site_funding => {:includes_special_funding => true}}} end @@@
Calling Child.with_permissions_to(:read) returns back multiple duplicates of children, since they can have multiple enrollments. In SQL, if I could tack on a 'group by "children.id"', it comes back without dups.
Granted, I'm still stuck on some older versions of software: DA is (0.5.2) , rails 2.3. Has this been addressed at all yet, or is there an easy solution?