Fix for foreignKey issue in #1685