Fixed an error: The foreign id check was inverted