Fix errors with null values in joins