We were getting errors like this in Reviewables in some cases:
ActiveRecord::StatementInvalid (PG::AmbiguousColumn: ERROR: column reference "category_id" is ambiguous LINE 4: ...TRUE) OR (reviewable_by_group_id IN (NULL))) AND (category_i...
The problem that was making everything go is that plugins can add their own custom filters for Reviewables. If one is doing an
INNER JOIN on topics, which has its own
category_id column, we would get the above AmbiguousColumn error. The solution here is to just make all references to the reviewable columns in the
viewable_by code prefixed by the table name e.g.