Fixed an issue with document joins