Closed prioux closed 8 years ago
While I cannot reproduce this bug, it seems caused by a known behaviour of undo_where
:
# Note that if a previous where() restriction was a long string
# with several subclauses, the entire string will be rejected
# as soon as somewhere inside we can detect that at least one
# subclause contained one of the attributes given in argument.
Activating the various debugging statements inside undo_where
during a filter query reveals that the SQL predicates to scope the results to a single user are typed as a single string:
STR (userfiles.user_id = 10) OR (userfiles.group_id IN (15,1,6,25,30) AND userfiles.data_provider_id IN (7,8,14,10))
This string is from Userfile.restrict_access_on_query
, which dynamically constructs the predicate. Unfortunately Userfile.restrict_access_on_query
cannot be refactored to use ActiveRecord's query builder as ActiveRecord does not support the OR
operator yet.
Short of having undo_where
parse and mangle the SQL predicate or extending ActiveRecord to support OR
, I do not see an easy way out of this bug.
For some reason I get weird numbers in my own (normal user) account in the CBRAIN service when looking at the filter headers in the userfiles index page.