Fix for subtle issue when selectig across many-to-many joins on tables with versioning